problem on C++ programming question

i have a question on C++ and i can't manage to solve it out since i'm new to C++. can you help me out? this is the question.
======================================
ask a user to enter starting point. then ask the user to enter end point. add the starting point repeatly until it reach the end point or less. finally, output the result each time the addition happen and at the end of program, display the number of the addition happen.
======================================
i hope you can help me to solve this problem. thanks.
yvonnesooAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
We cannot provide answers to school assignments.  That is grounds for removal from this site.  (for both you and the experts involved.)  We can provide only limitied help in accademic assignments.    We can answer specific (direct) questions, like you might ask your teacher.  We can review your work and post suggestions, again, like your teacher might do.

Do you have specific questions?
Do you have any work on this (incomplete even) that we can review?
0
azamiCommented:
Hmmm, the algorithm to solve the problem is written in the problem.  Break it into the steps described:

1. get start point from user
2. get end point from user
3. loop until condition (you reach end point or less); each iteration, add the start point, output the result, and increment a counter
4. output the counter

Since all of this is written in the problem, I don't think it's really your question.  But what is your question?
0
Ernest022699Commented:
Thank you, nietod, for trying to keep people honest.
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

tenetjaxCommented:
As a teacher of Computer Science it seems that your question on loops fits into the cirriculum about this time, so I am not going to answer the question but I will give you the notes I would give my class.

You have to use a loop which requires 3 things:
1) the initialization of the loop
2) the stopping point of the loop
3) the incrementation of the loop

I am sure you have been taught either the while loop or the for loop.  Since the user will enter a definitive starting and ending point use the for loop.  Here is the syntax for a for loop.

for(variable = starting point; variable <=ending point ; incrementation)
{
any work you need to do repeatedly goes in here

}

I don't think your teacher would want me to give you more than that.
0
yvonnesooAuthor Commented:
For your information, i'm not a student and i'm now working. I would like to increase my knowledge on C++ programming. But the question i request earlier is quite confuse and i can't solve it. Since, i don't know much about the string or value on C++, i need your help. Unfortunely, none of you can solve my problem. For the proposed answer, i don't know what is for loop at all.
0
nietodCommented:
Student or not, its in your best interest to attempt the problem yourself and have us review your work.  

If you don't know what a "for loop", it sounds like you have NO knowledge of C++.  (This is like one of the first things you would learn in a book.)   I recommend you but a book or two on introductory C++ programming.  One I recommend is Deital and Deital's "C++ How to Program"

Do you know what a "while loop" is?  If not, how are you leaning C++?
0
yvonnesooAuthor Commented:
i know while loop. as i said, i new to C++...and i'm seeking a person to help me out. do you understand what i'm saying about? if you are a good lectured, you will not let your client to frusfrated.
0
nietodCommented:
Okay, you can do this with a while loop.  

You need to ask the user to enter the starting point and ending point.  I assume the starting point is a number, right?  You can ask the user by printing a prompt like

cout << "Please enter a starting point: ";

then you can read the valeu they entered like

int SartPoint;

cin >> StartPoint;

Can you write a program that just gets the starting and ending point?
0
tenetjaxCommented:
int start;
int end
int counter;
int sum;

cin>>start;
cin>>end;

for(start; start <=end; start++)
{
sum+=start;
cout<<sum<<endl;
counter++;
}
cout<<counter;



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yvonnesooAuthor Commented:
Thank you. I understand now. May i know beside using for loop, can i use while or do? which one is better. lastly, how do i output the result each time the addition happen? it is mean i have to enter the start and end point before the addition can happen or there are other way to do that.
0
nietodCommented:
>> May i know beside using for loop, can i
>> use while or do
Yes.

>> which one is better
Choice between the "for" loop or eiher the "while" or "do" loops is a matter of preference.  A "for" will be the shortest, that is, it takes less lines of code than "while" or "do".  The choice between "while" and "do" is a little harder.  A "while" and a "do" loop are almost identical, except that a "do" loop will allways execute at least 1 iteration (because it tests after it completes an iteration), a "while"  loop might not perform even the first iteration (because it tests before each iteration).  So to choose between them you have to consider whethor or not you want the loop to always execture at least one time.  You have to ask youself are the times when the loop should never run even once?

>>  how do i output the result each time the
>> addition happen
The program already does that.  It uses

cout<<sum<<endl;

to do this.


>> i have to enter the start and end point before the
>> addition can happen or there are other way to do that
Of course you have to enter it first.  Otherwise the program doesn't know where to start/  In other words, it doesn't know what numbers to add unless it is told before it has to add them.  Its no different than a human.  You can't tell a human "Add two numbers, and when you tell me the result, I'll tell you which two numbers to add."  the same with a computer.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.