Calculate the average of ten numbers using arrays

clarence_cool03 0 Tallied Votes 288 Views Share

{-='Calculate the average of ten numbers using arrays'=-}

#include<stdio.h>
#define MAX_NUM 10

int main(void)
{
//  Local Declarations
    int num[MAX_NUM];
    int ave, i;
    int sum = 0;
    
//  Filling the Array 
    printf("Please enter 10 numbers: \n");
    for (i = 0; i < 10; i++)
    scanf("%d", &num[i]);
    
//  Display the Numbers            
    printf("Your numbers are: \n");
    for(i = 0; i < 10; i++)
    printf("%4d",num[i]);  
   
//  Calculate the Numbers
    for(i = 0; i < 10; i++)
    sum += num[i];
    ave = (sum / 10.0);
   
    printf("\nThe average of the ten numbers are: %d\n", ave);
    
    system("pause");
    return 0;
}// main