By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,128 Members | 1,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,128 IT Pros & Developers. It's quick & easy.

Help me in completing a program

P: 1
I have com across a program in which I should take 17 as a global constant.
I have to take 17 inputs.
for those inputs ..
I have to find
the number of even numbers entered
the number of odd numbers entered
the number of prime numbers entered
smallest number among those 17
largest number among those 17
factorial of the smallest number
the first number
the last number
power of the first number and the last number

These should come under a single main function.
I have done
number of even
number of odd
number of prime

I am finding some difficulties in finding
largest and smallest numbers
The main problem is I should not use arrays as well as any other functions for these..
So without using arrays
I have to find a solution..
Please can u help me in finding a solution using for loops,while loops
etc.
Dec 30 '06 #1
Share this Question
Share on Google+
3 Replies


vpawizard
P: 66
For largest, take a variable x containing -inf (theorotically, practically lowest number data type supports). Compare each of 17 elements with x. If element is greater than x, store it in x and proceed.
Dec 30 '06 #2

P: 15
Hope U Can Have A Variable (say Val).
1.store The First Number U Get As Input In It.
2.then After Getting The Next Number Check If It Is Greater Than Val, If It Is Exchange The Values.
3.repeat This For Every 17 Numbers Or So....
4.you Can Do The Vice-versa For The Lowest Number By Checking For <.

Try It..hope It Will Work..
Jan 2 '07 #3

P: 55
I have com across a program in which I should take 17 as a global constant.
I have to take 17 inputs.
for those inputs ..
I have to find
the number of even numbers entered
the number of odd numbers entered
the number of prime numbers entered
smallest number among those 17
largest number among those 17
factorial of the smallest number
the first number
the last number
power of the first number and the last number

These should come under a single main function.
I have done
number of even
number of odd
number of prime

I am finding some difficulties in finding
largest and smallest numbers
The main problem is I should not use arrays as well as any other functions for these..
So without using arrays
I have to find a solution..
Please can u help me in finding a solution using for loops,while loops
etc.

hi there,

it seems that we are very willing to help you, but for now i strongly suggest that you post something, coz some people here are too busy to encode codes from the scratch, so post something and we'll see..
ok

regards,
Jan 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.