Saturday, September 10, 2011

C Program To Find Sum And Average Of N Numbers

Algorithm
1) Read the limit
2) While n=count
3) Set
sum=sum+x
count+=1
4) Print sum and average


Variables used


n-The limit
count-To check limit
x-Numbers
sum-Sum
avg-Average


Program


#include<stdio.h>
void main()
{
int n,count=1;
float x,avg,sum=0;
printf("Enter the no: of terms");
scanf("%d",&n);
while (count<=n)
{
printf("Enter the number");
scanf("%f",&x);
sum=sum+x;
count+=1;
}
avg=sum/n;
printf("Sum of the n numbers is =%f",sum);
printf("Averege of the n numbers=%f",avg);
}


Output


Enter the no: of terms
3
Enter the number
1
Enter the number
2
Enter the number
3
Sum of the n numbers is =6
Averege of the n numbers=2


Tags : C Program To Find Sum And Average Of N Numbers,flowchart and algorithm  To Find Sum And Average Of N Numbers,c program to find sum of n numbers,c program to find average of n numbers

No comments:

Post a Comment