Sum of n Numbers:
This C program calculates the sum of n numbers.Source Code For Sum of n Numbers:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,sum=0;
clrcsr();
printf("how many numbers you want to add \n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+i;
}
printf("sum of %d numbers is %d",n,sum);
getch();

No comments:
Post a Comment