C Program to Accept Ten Numbers in Array and Print Average of it.

In this program, we will learn to read 10 numbers from user, calculate the average of these numbers and display it on screen.



Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
    int arr[10];
    int i;
    int sum = 0, avg = 0;
    //clrscr();
    printf("Enter 10 array elements\n");
    for(i = 0; i < 10; i++)
    {
        scanf("%d", &arr[i]);
    }
    for(i = 0; i < 10; i++)
    {
        sum = sum + arr[i];
    }
    printf("Sum is %d", sum);
    avg = sum / 10;
    printf("\nAverage of 10 numbers is %d", avg);
    getch();
}
Output
Enter 10 array elements
45 36 75 29 54 82 120 54 62 45
Sum is 602
Average of 10 numbers is 60





"Coding Hub - Learn to code" app now available on Google Play Store