Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
ive been working on this ques for hours...
Author Message
air_force91

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

rizzix

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

whts wrong with that? its easy !
morgoth

Posted: 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

Posted: 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

Posted: 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

Posted: 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

Posted: 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

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

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

Posted: 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

Posted: 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

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

or
 code: for i:0..101 by 5 put i end for
Tony's programming blog. DWITE - a programming contest.
Andy

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

mine goes infinitely long, take that tony!
thoughtful

Posted: 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
Andy

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

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

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 2  [ 21 Posts ]
Goto page 1, 2  Next
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: