Do while c++ loops problems

I am tasked to make two program using do while loops in c++. can anybody help me?

Exercise 1:

This is should be the display

sample 1
input 1: 1995
Input 2: 2009
Leap Years: 1996, 2000, 2004, 2008


sample 2:

input 1: 1899
input 2: 1903
there is no leap year to display!


the second activity is

input 1: 5
input 2: 10

display range of values: 6, 7, 8 ,9


ps. help me....



closed account (z05DSL3A)
can anybody help me?

We can help if you have a specific problem, if you are looking for someone to give you the code, you will probably be out of luck.

I would suggest you read: http://www.cplusplus.com/forum/beginner/1/
its okay..but would you give me the insights on how such things work....

i really do not know....

specially about the do while...loops...
1
2
3
4
do
{
   //something
} while (//condition) 
closed account (z05DSL3A)
Loot at the tutorial:
http://www.cplusplus.com/doc/tutorial/control/
For the first example, you should have two loops and one condition:

first, check if there are any leap years in between the inputs. If there are not, exit.

Set a counter equal to the first input.

The first loop should increment the counter until it is a multiple of four, as in modulus 4 = 0.

The second loop should print the counter out, add 4 to it, and then exit if it is greater than the second counter.

Of course, there are probably more efficient algorithms, but this should work.

The second one should be easy.

as for the do while loop:

1
2
3
4
5
6
do
{
              //something
}
while ( /* condition */ ); /* what this does is the same as a while loop,
 except it checks the condition after it excecutes the stuff in the "do {}". */
Last edited on
You could add that a do... while loop also is guaranteed to always execute at least once.
Example:
1
2
3
do {
    std::cout << "Although the condition evaluates to false, this is printed once.\n";
} while (1 == 2 || 1 > 9000 || (500 < 499 && 498 > 500));
Topic archived. No new replies allowed.