C++ Online Compiler
Example: C++ program to print half pyramid pattern of Alphabets
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to print half pyramid pattern of Alphabets #include <iostream> using namespace std; int main() { int rows; char alphabet = 'A'; 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 << alphabet << " "; } alphabet++; cout << endl; } } return 0; }
5
Output
Clear
ADVERTISEMENTS