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

Username:   Password: 
 RegisterRegister   
 ive been working on this ques for hours...
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
air_force91




PostPosted: Sun Nov 23, 2003 10:38 am   Post subject: ive been working on this ques for hours...

could u pls help me with this ques???i really can't get it...

Write a program which counts by 5's from 5 and adds the resulting numbers until the total is greater than 5

im really stuck here...i thought programming was fun when my class was into the intro...but now the teacher's giving out really hard ques...i can't seem to be getting it...im gonna have a nervous breakdown...ive also got a history essay to work on...plus romeo and juliet...ur help is really needed.................thanx..............
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Sun Nov 23, 2003 11:33 am   Post subject: (No subject)

whts wrong with that? its easy !
morgoth




PostPosted: Sun Nov 23, 2003 11:36 am   Post subject: (No subject)

what grade are you in and do you know what a for loop is or a infinite loop?
vexd




PostPosted: Sun Nov 23, 2003 11:41 am   Post subject: (No subject)

basically u need a variable.

a for loop

and keep adding the value of the For Loop to the variable
air_force91




PostPosted: Sun Nov 23, 2003 11:42 am   Post subject: (No subject)

im in grade 10...and yeah i do know what a loop and an infinite loop is...but i can't figure out the problem...i can't seem to be able to get the numbers in 5s and add them together...their supposed to be like:
5
10
15
20
35
40
75
air_force91




PostPosted: Sun Nov 23, 2003 11:52 am   Post subject: (No subject)

here's my code:

%loop entered
loop
for num:0..101
put num+5
put (num+5)+5
put (num+5)+(num+5)+5
delay(10000)
end for
end loop

now instead of going like this:

5
10
15
20
35

my output is:
5
10
15
6
11
17

can u tell me where ive gone wrong and what i could do?
air_force91




PostPosted: Sun Nov 23, 2003 11:58 am   Post subject: (No subject)

here's my code:

%loop entered
loop
for num:0..101
put num+5
put (num+5)+5
put (num+5)+(num+5)+5
delay(10000)
end for
end loop

now instead of going like this:

5
10
15
20
35

my output is:
5
10
15
6
11
17

can u tell me where ive gone wrong and what i could do?
air_force91




PostPosted: Sun Nov 23, 2003 12:55 pm   Post subject: (No subject)

i keep on trying but i don't get the output i need...
Sponsor
Sponsor
Sponsor
sponsor
Blade




PostPosted: Sun Nov 23, 2003 1:47 pm   Post subject: (No subject)

you basically do what was said above.. a variable then add teh value of the for loop, check it out.

code:
var total:int:=0 %declare a var of int, set it to 0
for i:0..101 by 5 %start a for loop, increment by 5 each time
  put i %display i
   total += i %add i to the total value
end for
Andy




PostPosted: Sun Nov 23, 2003 3:27 pm   Post subject: (No subject)

OR

code:

int count:=1
loop
    put count*5
    count+=1
end loop
Tony




PostPosted: Sun Nov 23, 2003 6:12 pm   Post subject: (No subject)

or
code:

for i:0..101 by 5
put i
end for
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Andy




PostPosted: Sun Nov 23, 2003 6:50 pm   Post subject: (No subject)

mine goes infinitely long, take that tony!
thoughtful




PostPosted: Sun Nov 23, 2003 6:52 pm   Post subject: (No subject)

dodge bro..isnt that bad, what if the guy doesnt know how to terminate the program Exclamation Exclamation Twisted Evil Razz Razz
Andy




PostPosted: Sun Nov 23, 2003 6:57 pm   Post subject: (No subject)

his assignment didnt ask for it to end...
thoughtful




PostPosted: Sun Nov 23, 2003 7:00 pm   Post subject: (No subject)

that was supposed to be a joke, well i guess i am not much of a joker...(note to self *no more jokes*)
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 2  [ 21 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: