write c program to find sum and average of n numbers
Answers
Answered by
3
Answer:
The given program is written in C language.
#include <stdio.h>
int main() {
int n,i;
float s=0.0,av=0.0,y;
printf("How many numbers?? ");
scanf("%d",&n);
printf("Enter the numbers...\n");
for(i=1;i<=n;i++) {
printf(">> ");
scanf("%f",&y);
s+=y;
}
av=s/(double)n;
printf("Sum: %f\n",s);
printf("Average: %f",av);
return 0;
}
Algorithm:
- Ask the user for the number of inputs.
- Add up all the numbers entered.
- Display the sum.
- Divide the sum by total number of inputs taken.
- Show the result.
Refer to the attachment.
•••♪
Attachments:
Answered by
3
Explanation:
here is your answer .
hope it is useful to you
Attachments:
Similar questions