Is this the right way to program this?

Solve a problem that has the user continually entering integers, one at a time, and assume these integers are in the range of 0 to 10 and calculates their sum until the sum is over 35. When done the sum and last numbered entered should be displayed. Use a loop of some kind for this one.


int j,sum=0;
do{
cin >> j;
sum+=j;
}while(sum<=35);
cout << sum << " "<< j;
Does it do what asked? If so, your program is fine. It is hard to do such simple program incorrectly. An adaptation of some definitive coding style and refraining from using namespace std; will be fine thought
i tend to over think my programs and it does work thank you for your help.
Topic archived. No new replies allowed.