Wednesday, October 12, 2011

Program code for diplay tringle shape input given by user(Using CPP language)


.Print This Pattern :
                                                 *
                                           *        *
                                        *      *      *
                                   *       *       *      *
                                       *        *      *  
                                            *       *
                                                *
#include<iostream.h>
#include<conio.h>
void main()
{
    int i,j,k,no;
    clrscr();
    cout<<"\n Enter the number==>>";
    cin>>no;
    for(i=0;i<no;i++)
    {
        for(k=40-(i*2);k>0;k--)
        {
            cout<<" ";
        }
        for(j=0;j<i;j++)
        {
            cout<<"  * ";
        }
        cout<<"\n\n";
    }
    for(i=no;i>0;i--)
    {
        for(k=40-(i*2);k>0;k--)
        {
            cout<<" ";
        }
        for(j=0;j<i;j++)
        {
            cout<<"  * ";
        }
        cout<<"\n\n";
    }
    getch();
}