C Program to print following triangle
*
**
***
****
code:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,j,k;
cout<<"Enter size of triangle(ex-5):";
cin>>n;
cout<<"
";
for(i=0;i<n;++i)
{
for(j=n;j>i;--j)
cout<<" ";
for(k=0;k<+i;++k)
cout<<"*";
cout<<"
";
}
getch();
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.