Monday, 8 July 2013

C++ program to print star pattern

#include<iostream.h>
#include<conio.h>
void main()
{
    int i;
    clrscr();
    for (i=1;i<=9;i++)
    {
    if(i==1||i==9)
    cout<<"\n    *";
    else if(i==2||i==8)
    cout<<"\n   * *   ";
    else if(i==3||i==7)
    cout<<"\n  * * *  ";
    else if(i==4||i==6)
    cout<<"\n * * * * ";
    else if(i==5)
    cout<<"\n* * * * *";
    else
    cout<<"\n";
    }
getche();
}

No comments:

Post a Comment