#include <iostream>
using namespace std;
int main()
{
int sum = 0; // Declare an int variable sum to accumulate the numbers
int lowerbound; // Set the initial sum to 0
int upperbound; // Sum from 1 to this upperbound
// Prompt user for an upperbound
cout << "Enter a integer: ";
cin >> upperbound;
cout << "Enter another integer: ";
cin >> lowerbound;
while (lowerbound <= 100 && upperbound <= 100)
{
sum = sum + upperbound++ + lowerbound++;
}
// Print the result
cout << "The total of the numbers " << upperbound << " and " << lowerbound << " is " << sum << endl;
}
garber
-3
Newbie Poster
Recommended Answers
Jump to PostIs there a problem? If so, please explain it. If not, this should be moved to Code Snippets.
Jump to PostI suggest replacing user input with hard coded values for testing. You should also tell us the expected output and the current output.
Have you tried stepping through the code with a debugger? This would be where I would start.
Actually, I would start with this line:
Jump to Post>> Why did I even try to use this site? Attitude is all people respond with!
Your refusal to read the helpful replies in this thread has nothing to do with our attitude, but more with yours.
Jump to PostTake a read through this:
http://www.cplusplus.com/doc/tutorial/control/Then give it another shot.
Please keep in mind my suggestion of:
I suggest replacing user input with hard coded values for testing. You should also …
Jump to PostCORRECT CODE.....
1) It's not correct code
2) Do not do homework for others. It's not your grade, and it is their future.
All 18 Replies
daviddoria
334
Posting Virtuoso
Featured Poster
garber
-3
Newbie Poster
TheSassyDragon
0
Newbie Poster
daviddoria
334
Posting Virtuoso
Featured Poster
garber
-3
Newbie Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
TheSassyDragon
0
Newbie Poster
garber
-3
Newbie Poster
Caligulaminus
35
Junior Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
Despairy
0
Light Poster
garber
-3
Newbie Poster
daviddoria
commented:
Still not listening to the suggestions! Give it another try and we can try to guide you. This problem is so short that we can't really help anymore without flat out writing it for you.
-3
Blackiey
0
Junior Poster in Training
daviddoria
334
Posting Virtuoso
Featured Poster
mir wasif
0
Newbie Poster
daviddoria
334
Posting Virtuoso
Featured Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
mir wasif
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.