Pages

Sunday, 20 May 2012

program to print the triangle value


83./*Write a program to print the triangle value*/

#include<stdio.h>
#include<conio.h>
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