Author |
Message |
Miko99
|
Posted: 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. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Blade
|
Posted: Thu Mar 27, 2003 11:39 am Post subject: (No 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... |
|
|
|
|
|
Miko99
|
Posted: Thu Mar 27, 2003 6:36 pm Post subject: (No 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. |
|
|
|
|
|
Blade
|
Posted: Thu Mar 27, 2003 7:08 pm Post subject: (No subject) |
|
|
lol yea, i'm taking grade 10 turing too... just started this semester ... no problem.. i'll help if i can |
|
|
|
|
|
Miko99
|
Posted: Fri Mar 28, 2003 8:47 am Post subject: (No 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. |
|
|
|
|
|
Miko99
|
Posted: Fri Mar 28, 2003 10:25 am Post subject: (No subject) |
|
|
How do i put both numbers a high and a low to the screen now? |
|
|
|
|
|
Blade
|
Posted: Fri Mar 28, 2003 11:38 am Post subject: (No 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
|
|
|
|
|
|
|
Dan
|
Posted: Fri Mar 28, 2003 12:09 pm Post subject: (No subject) |
|
|
for info on loops you can read this tutoral we have:
http://www.compsci.ca/bbs/viewtopic.php?t=370 |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Sponsor Sponsor
|
|
|
|