Saturday, December 31, 2011

Find sum of Entered number in 'C'

Example



#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,sum=0;
clrscr();
printf("Enter the number :");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
sum=sum+i;
}
printf("Total sum of given number is=%d",sum);
getch();
}
/*============================================================
OUTPUT
Enter the number :5
Total sum of given number is=10 */



No comments:

Post a Comment