Computer Science Canada

ive been working on this ques for hours...

Author:  air_force91 [ 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..............

Author:  rizzix [ Sun Nov 23, 2003 11:33 am ]
Post subject: 

whts wrong with that? its easy !

Author:  morgoth [ Sun Nov 23, 2003 11:36 am ]
Post subject: 

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

Author:  vexd [ Sun Nov 23, 2003 11:41 am ]
Post subject: 

basically u need a variable.

a for loop

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

Author:  air_force91 [ Sun Nov 23, 2003 11:42 am ]
Post 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

Author:  air_force91 [ Sun Nov 23, 2003 11:52 am ]
Post 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?

Author:  air_force91 [ Sun Nov 23, 2003 11:58 am ]
Post 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?

Author:  air_force91 [ Sun Nov 23, 2003 12:55 pm ]
Post subject: 

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

Author:  Blade [ Sun Nov 23, 2003 1:47 pm ]
Post 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

Author:  Andy [ Sun Nov 23, 2003 3:27 pm ]
Post subject: 

OR

code:

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

Author:  Tony [ Sun Nov 23, 2003 6:12 pm ]
Post subject: 

or
code:

for i:0..101 by 5
put i
end for

Author:  Andy [ Sun Nov 23, 2003 6:50 pm ]
Post subject: 

mine goes infinitely long, take that tony!

Author:  thoughtful [ Sun Nov 23, 2003 6:52 pm ]
Post subject: 

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

Author:  Andy [ Sun Nov 23, 2003 6:57 pm ]
Post subject: 

his assignment didnt ask for it to end...

Author:  thoughtful [ Sun Nov 23, 2003 7:00 pm ]
Post subject: 

that was supposed to be a joke, well i guess i am not much of a joker...(note to self *no more jokes*)

Author:  air_force91 [ Sun Nov 23, 2003 8:38 pm ]
Post subject: 

IM NOT A "HEEEEEEEEEEEEE"

Author:  Tony [ Sun Nov 23, 2003 9:48 pm ]
Post subject: 

we know that air_force, but dodge is slow Laughing

Author:  Andy [ Sun Nov 23, 2003 9:57 pm ]
Post subject: 

hey, calling me slow means you're calling whatdotcolor slow, and calling whatdotcolor slow will result in the wrath of the whatdotcolor man... lol jk its just that i'm not used to speaking politically correctly cuz i never had to...

Author:  air_force91 [ Tue Nov 25, 2003 8:37 am ]
Post subject: 

thanx...thanx for the codes...i asked my teacher yesterday and he told me the code but now the problem is...even his code doesn't result in :

5
10
15
25
40
65

see? they're not really counting by 5's ....they add up after 5....this is what i need...

Author:  Tony [ Tue Nov 25, 2003 11:18 am ]
Post subject: 

code:

var num:int := 5
loop
put num
num := num+5
end loop

8)

Author:  air_force91 [ Tue Nov 25, 2003 11:20 am ]
Post subject: 

thanx man...i got it now


: