Write a program that uses nested for loops to print the following pattern to the console
*******
******
*****
****
***
**
*
#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;
}
Comments
Leave a comment