
-----------------------------------
air_force91
Sun Nov 23, 2003 10:38 am

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..............

-----------------------------------
rizzix
Sun Nov 23, 2003 11:33 am


-----------------------------------
whts wrong with that? its easy !

-----------------------------------
morgoth
Sun Nov 23, 2003 11:36 am


-----------------------------------
what grade are you in and do you know what a for loop is or a infinite loop?

-----------------------------------
vexd
Sun Nov 23, 2003 11:41 am


-----------------------------------
basically u need a variable.

a for loop

and keep adding the value of the For Loop to the variable

-----------------------------------
air_force91
Sun Nov 23, 2003 11:42 am


-----------------------------------
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
Sun Nov 23, 2003 11:52 am


-----------------------------------
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
Sun Nov 23, 2003 11:58 am


-----------------------------------
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
Sun Nov 23, 2003 12:55 pm


-----------------------------------
i keep on trying but i don't get the output i need...

-----------------------------------
Blade
Sun Nov 23, 2003 1:47 pm


-----------------------------------
you basically do what was said above.. a variable then add teh value of the for loop, check it out.

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
Sun Nov 23, 2003 3:27 pm


-----------------------------------
OR


int count:=1
loop
    put count*5
    count+=1
end loop


-----------------------------------
Tony
Sun Nov 23, 2003 6:12 pm


-----------------------------------
or

for i:0..101 by 5
put i
end for


-----------------------------------
Andy
Sun Nov 23, 2003 6:50 pm


-----------------------------------
mine goes infinitely long, take that tony!

-----------------------------------
thoughtful
Sun Nov 23, 2003 6:52 pm


-----------------------------------
dodge bro..isnt that bad, what if the guy doesnt know how to terminate the program  :!:  :!:  :twisted:  :P  :P

-----------------------------------
Andy
Sun Nov 23, 2003 6:57 pm


-----------------------------------
his assignment didnt ask for it to end...

-----------------------------------
thoughtful
Sun Nov 23, 2003 7:00 pm


-----------------------------------
that was supposed to be a joke, well i guess i am not much of a joker...(note to self *no more jokes*)

-----------------------------------
air_force91
Sun Nov 23, 2003 8:38 pm


-----------------------------------
IM NOT A "HEEEEEEEEEEEEE"

-----------------------------------
Tony
Sun Nov 23, 2003 9:48 pm


-----------------------------------
we know that air_force, but dodge is slow :lol:

-----------------------------------
Andy
Sun Nov 23, 2003 9:57 pm


-----------------------------------
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...

-----------------------------------
air_force91
Tue Nov 25, 2003 8:37 am


-----------------------------------
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...

-----------------------------------
Tony
Tue Nov 25, 2003 11:18 am


-----------------------------------

var num:int := 5
loop
put num
num := num+5
end loop

 8)

-----------------------------------
air_force91
Tue Nov 25, 2003 11:20 am


-----------------------------------
thanx man...i got it now
