i forgot to put DO in my program. since i was instructed to use DO-WHILE LOOP. i still have the same output if i use this code. But better to have the DO inserted.
output:
0
0 2
0 2 4
0 2 4 6
0 2 4 6 8
0 2 4 6 8 10

#include <iostream.h>
#include<conio.h>
#include<stdio.h>
using namespace std;

int main()

{
 
int i=10;
int x=2;

int y=0;

while (x <= i)
{
    y = 0;
    while ( y <= x)
    {
        cout << y << " ";
        y += 2;
    }
    cout <<endl;
    x += 2;
}

return 0;

Edited 5 Years Ago by WaltP: Added CODE Tags again for the third time

1) Please use code tags.
2) Use <iostream> instead of <iostream.h> (and similar for the other headers)
3) Use more descriptive variable names. What are x? y? i?
4) You'll have to give us a better idea of the problem. What is the current output? What is the expected output?

i forgot to put DO in my program. since i was instructed to use DO-WHILE LOOP. i still have the same output if i use this code. But better to have the DO inserted.

Yes, you forgot to use DO. How you can forget DO when the assignment calls for it I'm not sure, but there you go.

So convert your loops into DO loops. Look them up in your book.

1) Please use code tags.
2) Use <iostream> instead of <iostream.h> (and similar for the other headers)
3) Use more descriptive variable names. What are x? y? i?
4) You'll have to give us a better idea of the problem. What is the current output? What is the expected output?

[QOUTE]
X Y AND I are my variables for counters.
current ouput:
0
0 2
0 2 4
0 2 4 6
0 2 4 6 8
0 2 4 6 8 10

expected output: the same output in current output. but i need to insert DO structure.

This article has been dead for over six months. Start a new discussion instead.