Author |
Message |
MPVoiD
|
Posted: Thu Jan 22, 2015 1:19 pm Post subject: Help |
|
|
My CompSci teacher wanted me to "write a function that returns a larger of two numbers". I'm extremely new at Turing and wondering what needs to be done in order for this to work.
This is what I have right now, but it comes back with errors.
var num1, num2 :int
put "Enter two different numbers."
get num1
get num2
if num1 > num2 then
put num1
if num2 > num1 then
put num2 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Zren
|
Posted: Thu Jan 22, 2015 1:27 pm Post subject: RE:Help |
|
|
What does the error say? |
|
|
|
|
|
MPVoiD
|
Posted: Thu Jan 22, 2015 7:45 pm Post subject: Re: Help |
|
|
It says "Syntax error at 'end of file'. Expected 'end if'. |
|
|
|
|
|
bubb4h0t3p
|
Posted: Thu Jan 22, 2015 7:46 pm Post subject: Re: Help |
|
|
you forgot to close your if statements with "end if"
Turing: |
var num1, num2 :int
put "Enter two different numbers."
get num1
get num2
% just puts a blank line
put ""
% you're if statements weren't closed with an "end if"
if num1 > num2 then
put num1
end if % < always add after your if statement
if num2 > num1 then
put num2
end if % < here too
|
By the way everything after a "%" sign is a comment and ignored by the compiler |
|
|
|
|
|
MPVoiD
|
Posted: Thu Jan 22, 2015 7:52 pm Post subject: Re: Help |
|
|
oh, so I need to type "end if" after each if statment. Thank you very much - it work's now. |
|
|
|
|
|
MPVoiD
|
Posted: Sat Jan 24, 2015 12:39 pm Post subject: Re: Help |
|
|
How would I make this program work using a function? |
|
|
|
|
|
Insectoid
|
Posted: Sat Jan 24, 2015 4:06 pm Post subject: RE:Help |
|
|
Do you know how to use functions at all? |
|
|
|
|
|
Zren
|
|
|
|
|
Sponsor Sponsor
|
|
|
|