Computer Science Canada

How easy is this program?

Author:  J2S [ Thu Nov 23, 2006 8:54 pm ]
Post subject:  How easy is this program?

I'm trying to make one that has the user enter a series of numbers and the program will find the largest number once the user exits. It's kind of hard though. Someone help. Shocked

Author:  ericfourfour [ Thu Nov 23, 2006 9:02 pm ]
Post subject: 

Well you get a number see if it is greater than the largest. If it is it becomes the largest. Repeat.

Author:  J2S [ Thu Nov 23, 2006 9:05 pm ]
Post subject: 

code:
loop
    exit when num = -999
    get num
    n := n + 1
    if n > num then
   
end loop

Author:  J2S [ Thu Nov 23, 2006 9:06 pm ]
Post subject: 

I still don't understand it. Harhar Embarassed

Author:  ericfourfour [ Thu Nov 23, 2006 10:14 pm ]
Post subject: 

This is not a hard problem. If you want to keep track of the largest number what do you do? If you want to check if a number is greater than the largest number what do you do?

Author:  Clayton [ Thu Nov 23, 2006 10:20 pm ]
Post subject: 

pseudo:

loop
    get a number
    exit if number = -1000000 (or whatever you want)
    if the number is bigger than the previous number, it is now the largest number
end loop
output the largest number


: