C++ Online Compiler
Example: Right-angled Number Pyramid in C++
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Right-angled Number Pyramid #include <iostream> using namespace std; int main() { int rows = 5; // Number of rows for the pyramid // Outer loop for rows for (int i = 1; i <= rows; ++i) { // Inner loop for printing numbers in each row // It prints numbers from 1 up to the current row number 'i' for (int j = 1; j <= i; ++j) { cout << j; } cout << endl; // Move to the next line after each row is printed } return 0; }
Output
Clear
ADVERTISEMENTS