Wednesday, 24 July 2013

//PROGRAM TO PRINT THE COMPLETE PYRAMID
/*MADE BY KRISHNA AGARWAL*/
#include<iostream>
using namespace std;
int main()
{
    int i,j,k,n,p;
    cout<<"enter the odd no. of lines\n";
    cin>>p;
    n=(p/2)+1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n-i;j++)
            cout<<" ";
        for(k=1;k<=2*i-1;k++)
            cout<<"*";
        cout<<endl;
    }
    for(i=n;i>=1;i--)
    {
        for(j=n;j>=i;j--)
            cout<<" ";
        for(k=1;k<=2*i-3;k++)
            cout<<"*";
        cout<<endl;
    }
    return 0;
 }

No comments:

Post a Comment