Answer to Question #262781 in C++ for Urooj

Question #262781

Write a program that uses nested for loops to print the following pattern to the console

*******

******

*****

****

***

**

*


1
Expert's answer
2021-11-09T10:21:08-0500
#include <iostream>
using namespace std;
void pattern(int x)
{
    for (int i = x; i > 0; i--) {
 
        for (int j = 0; j < i; j++) {


            cout << "*";
        }
 
        cout << endl;
    }
}
int main()
{
    int x = 7;
    pattern(x);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS