Example
Input :
Input rows: 5
Output :
* *** ***** ******* *********
Required Knowledge
Basic C++ programming, for loop, nested loop, if-else
Program to print pyramid star pattern series
include <iostream> using namespace std; int main() { int i, j, rows;/* Input number of rows to print */
cout<<"Enter number of rows : ";
cin>>rows;
/* Iterate through rows */
for(i=1; i<=rows; i++)
{
/* Print leading spaces */
for(j=i; j<rows; j++)
{
cout<<" ";
}
/* Print star */
for(j=1; j<=(2*i-1); j++)
{
cout<<"*";
}
/* Move to next line */
cout<<"\n";
}
return 0;
}