Sunday, 11 December 2011

Write a program to print the triangle value in c

#include
#include
main()
{
int n,sum=0;
clrscr();
printf("Enter any value");
scanf("%d",&n);
while(n>0)
{
sum=sum+n;
n--;
}
printf("Triangular value is %d",sum);
getch();
}


OUTPUT

Enter any value : 5

Triangular value is 15

No comments:

Post a Comment