Computer Science Canada

Need help displaying the lowest of 5 numbers to the screen

Author:  Miko99 [ Thu Mar 27, 2003 11:01 am ]
Post subject:  Need help displaying the lowest of 5 numbers to the screen

When the user enters in 5 numbers, hwo do i get it to display the lowest and highest to the screen. I have to write 3 programs. 1 to display the lowest, 1 to display the highest and 1 to display both. Thanks for the help guys.

Author:  Blade [ Thu Mar 27, 2003 11:39 am ]
Post subject: 

first you would set a high and low variable
code:

var high:int:=-9999
var low:int:=9999

you use it like that because you are comparing the high to the numbers they have entered... so thats what you do next
code:
if(num > high)then
high:=num

you do the same for the low... so
code:
if(num < low)then
low:=num
end if

then you put it in a loop to do it to every number...

Author:  Miko99 [ Thu Mar 27, 2003 6:36 pm ]
Post subject: 

Thanks man your the coolest. I am taking a grade 10 turing class even tho im in grade 12. test tommorow so i may be on in the morning requesting help lol.

Author:  Blade [ Thu Mar 27, 2003 7:08 pm ]
Post subject: 

lol yea, i'm taking grade 10 turing too... just started this semester Very Happy... no problem.. i'll help if i can

Author:  Miko99 [ Fri Mar 28, 2003 8:47 am ]
Post subject: 

How do i do a loop in turring? i know how to in Java, and C++ but not in turring!! help me! its a for loop.

Author:  Miko99 [ Fri Mar 28, 2003 10:25 am ]
Post subject: 

How do i put both numbers a high and a low to the screen now?

Author:  Blade [ Fri Mar 28, 2003 11:38 am ]
Post subject: 

Delta wrote:
code:

var low:int:=9999
var num:int

for i : 1.. 6
    put "Enter in a number"
    get num
    if (num < low)then
        low := num
    end if
    cls
end for
put "The Lowest number is: ",low


delta wrote this for you in one of your other posts... you would just add in the high as well... so..
code:

var low:int:=9999
var high:int:=-9999
var num:int

for i : 1.. 6
    put "Enter in a number"
    get num
    if (num < low)then
        low := num
    eslif(num>high)then
        high:=num
    end if
    cls
end for
put "The Lowest number is: ",low
put "The highest number is: ",high

Author:  Dan [ Fri Mar 28, 2003 12:09 pm ]
Post subject: 

for info on loops you can read this tutoral we have:

http://www.compsci.ca/bbs/viewtopic.php?t=370


: