C++ Online Compiler
Example: Full Pyramid Pattern in C++
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Full Pyramid Pattern #include <iostream> using namespace std; int main() { // Step 1: Declare variable for number of rows int rows; // Step 2: Prompt user for input cout << "Enter the number of rows for the full pyramid: "; cin >> rows; // Step 3: Outer loop for rows for (int i = 1; i <= rows; ++i) { // Step 4: Inner loop to print leading spaces // Number of spaces decreases with each row for (int j = 1; j <= rows - i; ++j) { cout << " "; } // Step 5: Inner loop to print asterisks // Number of asterisks increases: (2*i - 1) for (int k = 1; k <= 2 * i - 1; ++k) { cout << "*"; } // Step 6: Move to the next line after each row cout << endl; } return 0; }
Output
Clear
ADVERTISEMENTS