I would do something like this:
Ask the user to input a number
Set that number as the current maximum
for i = 1 to however many numbers the user wants to enter - 1
Have the user input a number
If that number is bigger than your current maximum number
Set that number as the current maximum |
So you would need four variables: one representing how many numbers the user wants to enter (
a in your code), one for the loop counter (
x in your code), one for the user's input, and one for the current maximum number.
By the way, don't be afraid to give your variables more descriptive names -- it won't slow your program (or the compiler) down, don't worry. :)
(Although single letter variables are okay for loop counters, like
x in your example -- though
i is more often used than
x for that purpose, but whatever.)