C++ Online Compiler
Example: Half Pyramid Pattern in C++ language of Stars using For loop
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Half Pyramid Pattern in C++ language of Stars using For loop #include <iostream> using namespace std; int main() { int r = 0, i, j; // r - denotes the number of rows cout << "-----To print the half pyramid enter the number of rows-----\n"; cin >> r; cout << "\n"; for (i = 1; i <= r; ++i) { for (j = 1; j <= i; ++j) cout << "* "; cout << "\n"; } return 0; }
8
Output
Clear
ADVERTISEMENTS