Write a program in C++ to display the pattern like a pyramid using asterisk and each row contain an odd number of asterisks.
#include <iostream>
using namespace std;
void main()
{
int i,j,n;
cout<<"Input number of rows for this pattern :";
cin>>n;
for(i=0;i<n;i++)
{
for(j=1;j<=n-i;j++)
cout<<" ";
for(j=1;j<=2*i-1;j++)
cout<<"*";
cout<<"\n";
}
system ("pause");
}
Write a program in C++ to display the pattern like a pyramid using asterisk and each row contain an odd number of asterisks.
Reviewed by Unknown
on
May 18, 2017
Rating:
No comments: