Write a program to find sum and average of 10 integer numbers stored in an array.

This answer is restricted. Please login to view the answer of this question.

Login Now
#include <stdio.h>

int main()
    int array[50], i, n, sum = 0;
    float avg;

    printf("How namy numbers? ");
    scanf("%d", &n);

    for(i=0; i<n; i++)
        printf("Enter the %d numbers: ", i + 1);
        scanf("%d", &array[i]);

    for (i = 0; i < n; i++)
        sum = sum + array[i];

    printf("The sum of 10 numbers you entered is=%d\n", sum);
    avg = (float)sum / n;
    printf("The avg of the 10 numbers you entered is=%.2f\n", avg);
    return 0;

The output of above program is

How namy numbers? 5
Enter the 1 numbers: 1
Enter the 2 numbers: 2
Enter the 3 numbers: 3
Enter the 4 numbers: 4
Enter the 5 numbers: 5
The sum of 10 numbers you entered is=15
The avg of the 10 numbers you entered is=3.00


If you found any type of error on the answer then please mention on the comment or report an answer or submit your new answer.
Leave your Answer:

Click here to submit your answer.

  Loading . . .