Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Write a code in C++ using the “do-while” loop to display them as given below.

******
*****
****
***
**
*

Solution:

Source code:

#include <iostream>

using namespace std;

int main ()

int x = 6, i, j;

i = 6;

do

j = 1;

do

cout << "* ";

++j;

while (j <= i);

cout << "\n";

--i;

}
while (i >= 1);

return 0;
}

Output:

******
*****
****
***
**
*

Output screenshot:

You might also like