*
***
*****
******* (in this pyramid n=4)
==================================================
#include<iostream>
#include<conio.h>
#include<iomanip>
using namespace std;
int main()
{
int n;
cout<<"Enter any number = ";cin>>n;
static int a=1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=4-i;j++)
{
cout<<" ";
}
for(int k=1;k<=a;k++)
{
cout<<"*";
}
a=a+2;
cout<<endl;
}
getch();
return(0);
}
No comments:
Post a Comment