C++ Online Compiler
Example: C++ program to print half pyramid pattern of numbers
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to print half pyramid pattern of 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 = 1; i <= rows; i++) { for (int j = 1; j <= i; j++) { cout << j << " "; } cout << endl; } } return 0; }
5
Output
Clear
ADVERTISEMENTS