Help Please! New to C
I'm sure this is very simply but please explain:
How can I find the greatest number in a list the user has entered?
I just don't get how you could compare numbers listed under the same variable.
Thanks for your time!
If you want to do it without arrays, you need two variables (it can't be done with just one). Just initialize both (I'll call them inp and max) to the lowest value possible and then follow these two steps:
- get a number (from user) and put in inp
- copy inp into max if inp exceeds max
Put these in a loop; when the loop ends (user hits X or something) you can read the largest value in the list out of max.
This procedure can easily generalized to find the largest value in an array, which is slightly more useful than getting the largest value inputted from the user.
Thanks for your help man! I got it to work w/o using an array, Im new to this and just made it more complicated than it was. Appreciate the help...