Computer Science, asked by shs0919192madhvi, 2 months ago

write c program to find sum and average of n numbers​

Answers

Answered by anindyaadhikari13
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:

  1. Ask the user for the number of inputs.
  2. Add up all the numbers entered.
  3. Display the sum.
  4. Divide the sum by total number of inputs taken.
  5. Show the result.

Refer to the attachment.

•••♪

Attachments:
Answered by divya976865
3

Explanation:

here is your answer .

hope it is useful to you

Attachments:
Similar questions