Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Problem statement:
You are required to write a program in which the program will ask the user to enter Lower limit and Upper limit for a loop. It means that loop will start from the lower limit and will execute till the upper limit. After taking the input, the program should show the sum of all the numbers from lower limit to upper limit in each iteration of the loop. For example if the user enters 3 as lower limit and 8 as upper limit. The output should be as:
3 7 12 18 25 33
What you are doing here is you are adding the lower limit into the number next to it and showing it in the same iteration.
Also the program will count the even and odd numbers in the output. In this example, the count of the even numbers will be 2 and the odd numbers will be 4. So the final output would be
C++

Posted
Comments
Jochen Arndt 20-Nov-15 6:21am    
This is probably an assignment / homework.

Show what you have tried so far and where you got stuck. Then you might get help. But you won't get the whole prgram here.

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

This isn't complicated, not really.
Break it into parts, and do each in turn. Start by creating a program and get it to read two numbers from the user. Then get it to make sure they are "reasonable" - i.e. that the upper limit is greater than the lower!

When that works, make a loop and check that works correctly.

Finally, add the addition and output code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900