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

Username:   Password: 
 RegisterRegister   
 Mod command problem? i keep on getting the same error?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
batman12




PostPosted: Tue Dec 20, 2005 8:07 pm   Post subject: Mod command problem? i keep on getting the same error?

hello,
i am a grade 10 kid and we are learning in turing in our computer engineering course. we have to make a program that displays all the numbers for 1 to 1000 that is divisible by three. i used for loop using mod but i keep on getting the same error. any suggestion? thanks

my solution
%description:show the user all the integers that are divisible by 3 and show the result.
for count:1..1000
if ((count mod 3 ))=0),then
put " you can have", count ,"that are divisble by three."
end loop


I get this error saying " syntax error at ')' expected 'then'"
please give me some suggestion that would help me out. i looked the at tutorials for for loops but didn't help me out. any sugggestions would be aprreciated. thanks.
Sponsor
Sponsor
Sponsor
sponsor
iker




PostPosted: Tue Dec 20, 2005 8:33 pm   Post subject: (No subject)

heres a suggestion: learn how to use
[1]for loops
[2]if commands
[3]any other basic commands that you don't know

The problem with your 'program', if thats what you want to call it, is that it isn't properly coded

try using this as an example
(var) is a variable
(n#) is a number
code:

for (var) : (n1) .. (n2)
    if (n3) mod (n4) = 0 then
        put %words
    end if
end for
batman12




PostPosted: Tue Dec 20, 2005 8:43 pm   Post subject: (No subject)

iker wrote:
heres a suggestion: learn how to use
[1]for loops
[2]if commands
[3]any other basic commands that you don't know

The problem with your 'program', if thats what you want to call it, is that it isn't properly coded

try using this as an example
(var) is a variable
(n#) is a number
code:

for (var) : (n1) .. (n2)
    if (n3) mod (n4) = 0 then
        put %words
    end if
end for
it give me a error on the solution it gives me. can u please explain?thanks for the help iker.thanks.
Bored




PostPosted: Tue Dec 20, 2005 8:47 pm   Post subject: Re: Mod command problem? i keep on getting the same error?

batman12 wrote:

my solution
%description:show the user all the integers that are divisible by 3 and show the result.
for count:1..1000
if ((count mod 3 ))=0),then
put " you can have", count ,"that are divisble by three."
end loop


I get this error saying " syntax error at ')' expected 'then'"
please give me some suggestion that would help me out. i looked the at tutorials for for loops but didn't help me out. any sugggestions would be aprreciated. thanks.


first off you don't need the brackets around count mod 3 they do absoloutely nothing and when it say error at ')' expected then it means that where you have the '),' you should have then and just delete the '),' i have no idea why you have them there
Geminias




PostPosted: Tue Dec 20, 2005 10:15 pm   Post subject: (No subject)

code:

for count:1..1000
if ((count mod 3 ))=0),then
put " you can have", count ,"that are divisble by three."
end loop


syntax errors, put in simplest terms mean that there is an error in the format of your code. Change it to..

code:

for count : 1 .. 1000
    if count mod 3 = 0 then
        put "The number: ", count, " is divisble by three."
    end if
end for

[/code]
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  [ 5 Posts ]
Jump to:   


Style:  
Search: