
-----------------------------------
KONjbnj
Tue Apr 12, 2005 8:11 am

Loop help
-----------------------------------
hello,
i have a problem how do u make it so that when you loop 2 variables they do not have the same value  ie.  

a program which will ask the user to enter two integer numbers. You want to swap the numbers so that larger of the two numbers is stored in the variable, Large, and the smaller of the two is stored in the variable, Small. and then loop so it asks the user to eneter 2 more. 

whenever i do this it keeps the value of the numbers which i used the second time  can anyone help??/

-----------------------------------
Token
Tue Apr 12, 2005 8:24 am


-----------------------------------
here ya go, what it does is checks to see if its larger then the largest variable, look at it to see qwhat i mean 


var a, b, largest : int := 0

loop
    put "Enter data: " ..
    get a
    put "Enter data: " ..
    get b

    if largest > a and largest > b then

    elsif a > b then
        largest := a
    elsif b > a then
        largest := b
    end if
    put "The largest number entered so far was ", largest


end loop


-----------------------------------
Martin
Tue Apr 12, 2005 8:24 am


-----------------------------------
KONjbnj, I don't have a clue what you're talking about.

-----------------------------------
StarGateSG-1
Tue Apr 12, 2005 11:06 am


-----------------------------------
I think I understand it after reading for 15 minutes, but this seems like a school question, so I won't give you the code.

but the idea you want is to have a tempvar

variables
tempa
tempb
largest
smallest

Body
loop
Ask for first number
Move it to temp
Ask for second number
Move it to temp
check for largest with first number
move to largest
check for largest with second number
move to largest check
check for smallest number with first number
move to smallest
check for smallest number with second number
The largest number so far was Bah
end loop

