0

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 by WaltP: Added CODE Tags again for the third time

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by daviddoria
0

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?

0

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.

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.