Tuesday, March 19, 2013

Pyramid 3

Program:

#include<iostream>

using namespace std;

int main()

{

        int n,i,j;
    cout<<"Enter n : ";
    cin>>n;
    for(i=0;i<n;i++)
    {
        for(j=0;j<=(n-i-2);j++)
        { cout<<" "; }
        for(k=0;k<=i;k++)
        { cout<<"*"<<" ";}
        cout<<endl;
    }
       
    return 0;

}



Output:

Enter n : 4

   *
  * *
 * * *
* * * *

0 comments:

Post a Comment