Wednesday, 9 January 2013

printing * in triangle shape


              *
             * *
            * * *
           * * * *

#include<iostream.h>
using namespace std;
main()
{

int i=0;
for(i=5;i>=1;i=i-1)
{
cout<<" ";
}
cout<<"*\n";
for(i=4;i>=1;i=i-1)
{
cout<<" ";
}
for(i=2;i>=1;i=i-1)
{
cout<<"* ";
}
cout<<"\n";
for(i=2;i>=1;i=i-1)
{
cout<<" ";
}
for(i=4;i>=1;i=i-1)
{
cout<<"* ";
}
cout<<"\n";

for(i=6;i>=1;i=i-1)
{
cout<<"* ";
}
system("pause");
}

No comments:

Post a Comment