C++ Online Compiler
Example: C++ program to print inverted pyramid pattern of Stars
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to print inverted pyramid pattern of Stars #include <iostream> using namespace std; int main() { int rows, j; cout << "Enter the number of rows: "; cin >> rows; if (rows > 0) { cout << endl; for (int i = rows; i >= 1; i--) { for (int leet = 0; leet < rows - i; leet++) cout << " "; for (j = i; j <= 2 * i - 1; j++) cout << "* "; for (j = 0; j < i - 1; j++) cout << "* "; cout << endl; } } return 0; }
5
Output
Clear
ADVERTISEMENTS