Qbasicnews.com

Full Version: Not sure how to write this
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Write a program that sums up all the multiples of 3 from 3 to 100 (of course the last one would be 99, not 100).

The total of all multiples of 3 from 1 to 100 is 1683 Write a program that keeps reading integers from the user until the number -1 is entered. Then print out the count of the numbers entered and their sum. See the sample input/output below for details. Notice that the message changes after the first number is entered. You should use a "priming read" for this program.

Please enter an integer (-1 to stop): ? 3
Please enter another integer (-1 to stop): ? 6
Please enter another integer (-1 to stop): ? 7
Please enter another integer (-1 to stop): ? -1
The sum of the 3 numbers you entered is 16
This looks like homework. Please read the forum rules regarding this.
the problem is i don't even know how to plan the logic
didn't want neone to actually write it out for me, just explain it thoroughly for me on all three counts
I do not mean to come across as a snob here, but this program is very basic.

This program requires a simple loop and two counters (one for the number of times looped, and one to hold the sum). Many future programs will be built on contructs like this; if you are having trouble imagining the looping program flow, I'm sure your next project will be even more confusing.

If you cannot understand the logical flow needed for this program, I would go to your teacher and ask for additional help as soon as possible.

*peace and goodluck!*

Meg.

Anonymous

LOL?
I'm locking this thread as its a duplicate of the thread at http://forum.qbasicnews.com/viewtopic.php?t=9135.