Saturday, 10 December 2011

a program to print a triangle given value by user in c

#include
#include
main()
{
int i,j,k,l,n;
clrscr();
printf("Enter any value");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
printf("*");
}
for(l=1;l {
printf("*");
}
printf("\n");
}
getch();
}


OUTPUT


Enter any value: 5


*
***
*****
*******
*********

No comments:

Post a Comment