C++ Online Compiler
Example: Number Pyramid with Repeating Digits in C++
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Number Pyramid with Repeating Digits #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 the current row number 'i' // It prints 'i' for 'i' times for (int j = 1; j <= i; ++j) { cout << i; // Print the row number itself } cout << endl; // Move to the next line } return 0; }
Output
Clear
ADVERTISEMENTS