Array Value Average

Take an array of integer data type of size 5. Scan the values from the user. Now print the average of integers which are greater than 100.

#include<stdio.h>
int main()
{
    int a[5],i,sum=0,count=0,avg;
    for(i=0; i<5; i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>100)
        {
            count++;
            sum=sum+a[i];
        }
    }
    avg=sum/count;
    printf("avg=%d",avg);
    return 0;
}

 

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *