Pages

Sunday, 20 May 2012

program to print a triangle


72./*Write a program to print a triangle.*/

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,j;
clrscr();
printf("Enter The Number:");
scanf("%d",&n);
for(i=n+1;i>0;i--)
{
for(j=0;j<i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}

OUTPUT:-
            Enter The Number: 5
            *****
            ****
            ***
            **
            *

No comments:

Post a Comment