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<<“nt”;

for(i=0;i<n;++i)
{
for(j=n;j>i;–j)
cout<<” “;
for(k=0;k<+i;++k)
cout<<“*”;
cout<<“nt”;
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *