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