Finding Mean Value From Array C Programming

In previous post we discussed about how to sort array elements using bubble sort function. In following simple program we will create a function which will accept an array as an input. Furthermore that function will return mean value of the array elements. Mean value is the average of all array elements. Mean value is calculated by summing all values of the array and dividing by the total number of array elements.


#include <stdio.h>

int mean(int arr[], int size); // function prototype

int main(void){

int arrayName[10] = {90,44,33,83,49,34,51,84,56,44}; // defined an array with 10 elements

//output each element of array
printf("Original values of the arraynn");
printf("Array indextttValuen");
for(int j=0; j<10; j++){
printf("%11dttt%4dn", j, arrayName[j]);

int a = mean(arrayName, 10); // function call

printf("nnMean Value is: %d (excluding fractional part)", a);

return 0;

//function definition
int mean(int arr[], int size){
int sum = 0;
for(int i=0; i<size; i++){
sum = sum + arr[i];
return sum/size;



Leave a Comment

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