Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Syntax Error Help!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Hoshi




PostPosted: 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 Question
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: 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.
Tony




PostPosted: Mon Dec 19, 2011 5:10 pm   Post subject: RE:Syntax Error Help!

refer to examples in turing documentation -- for
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Hoshi




PostPosted: 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
Tony




PostPosted: Mon Dec 19, 2011 5:35 pm   Post subject: RE:Syntax Error Help!

I don't know. What does the compiler say?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Hoshi




PostPosted: Mon Dec 19, 2011 8:22 pm   Post subject: RE:Syntax Error Help!

for num it says assigned value is the wrong type.
Insectoid




PostPosted: Mon Dec 19, 2011 8:39 pm   Post subject: RE:Syntax Error Help!

Integers don't like being divided. They love div though.
tg851




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
chipanpriest




PostPosted: 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
Aange10




PostPosted: 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.


Turing:

% Diving
put 5 / 2 % = Outputs 2.5 REAL
put 10 / 2 % = Outputs 2 REAL
put 21 / 2 % = Outputs 10.5 REAL
% Div { Divides without computing Remainders }
put 5 div 2 % Outputs 2 INT
put 10 div 2 % Outputs 5 INT
put 21 div 2 % outputs 10 INT
% Round
put round (5 / 2) % Outputs 3 INT
put round (10 / 2) % Outputs 5 INT
put round (21 / 2) % Outputs 11 INT
% Ceil {Rounds UP Always}
put ceil (5 / 2) % Outputs 3 INT
put ceil (10 / 2) % Outputs 5 INT
put ceil (21 / 2) % Outputs 11 INT
% Floor {Rounds Down Always}
put floor (5 / 2) % Outputs 2 INT
put floor (10 / 2) % Outputs 5 INT
put floor (21 / 2) % Outputs 10 INT
chipanpriest




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: