Computer Science Canada Syntax Error Help! |
Author: | Hoshi [ Mon Dec 19, 2011 4:57 pm ] |
Post subject: | Syntax Error Help! |
the for count command is not working. Turing says that the variable is not declared. Doesn't the count command not need to be declared ![]() |
Author: | Insectoid [ Mon Dec 19, 2011 5:09 pm ] |
Post subject: | RE:Syntax Error Help! |
"for count" isn't a command. "for i : 1..10" is though. |
Author: | Tony [ Mon Dec 19, 2011 5:10 pm ] |
Post subject: | RE:Syntax Error Help! |
refer to examples in turing documentation -- for |
Author: | Hoshi [ Mon Dec 19, 2011 5:28 pm ] |
Post subject: | RE:Syntax Error Help! |
what is wrong with this var depth :int var sum :int get depth for num: 1 .. depth sum:= depth-3+2/num exit when sum=num put sum-num end for |
Author: | Tony [ Mon Dec 19, 2011 5:35 pm ] |
Post subject: | RE:Syntax Error Help! |
I don't know. What does the compiler say? |
Author: | Hoshi [ Mon Dec 19, 2011 8:22 pm ] |
Post subject: | RE:Syntax Error Help! |
for num it says assigned value is the wrong type. |
Author: | Insectoid [ Mon Dec 19, 2011 8:39 pm ] |
Post subject: | RE:Syntax Error Help! |
Integers don't like being divided. They love div though. |
Author: | tg851 [ Wed Dec 21, 2011 11:57 am ] |
Post subject: | RE:Syntax Error Help! |
div will divide integers.floor,ceil,and round will divide 2 numbers to produce an integer of the result depending on the command |
Author: | chipanpriest [ Wed Dec 21, 2011 12:24 pm ] |
Post subject: | RE:Syntax Error Help! |
its because you are trying to divide an integer, which you cannot do unless you round it. an integer is a whole number, thus if you are dividing 3 by 2, you will get a decimal, which is not an integer |
Author: | Aange10 [ Wed Dec 21, 2011 12:29 pm ] | ||
Post subject: | RE:Syntax Error Help! | ||
Which just means that you can't divide 3/2 and store it as an integer. 1.5 is not an integer. However, you may store that into a real. Here is an example of Ceil,Dividing,Div, and floor.
|
Author: | chipanpriest [ Wed Dec 21, 2011 12:35 pm ] |
Post subject: | RE:Syntax Error Help! |
Yea what he said and actually i didnt know about the ceil and floor commands either so thanks for that :p |