Monday, 21 July 2014

Program to print hollow triangle

#include<iostream.h>
#include<conio.h>
void main()
{
int i;
clrscr();
cout<<"\n";
for(i=1;i<=11;i++)
cout<<" ";
cout<<"*";
for( i=1;i<=5;i++)
{
if(i<5)
{
cout<<"\n";
for(int j=4;j>=i;j--)
cout<<"  " ;
cout<<" * ";
for(int k=1;k<=2*i-1;k++)
cout<<"  ";
cout<<" * ";
 }
else
{
cout<<"\n";
for(int s=1;s<=8;s++)
cout<<" * ";
}
}
getch();
}

Output:






No comments:

Post a Comment