0
Why its not printing the output ??
#include <stdio.h> int avg(int array[], int size); int main() { int x[100], k,n; printf("Enter this size of an array: \n"); scanf("%d", &n); for(k = 0; k<n; k++) { scanf("%d", &x[k]); } printf("Average of array elements= %d", avg(x,n)); return 0; } int avg (int array[], int size) { int *p, sum=0, i; p=array; for(i=0; i<size; i++) { sum = sum + *(p+i); } return (sum/size); }
1 Answer
+ 4
Works fine. I entered:
3 4 7 10
as input.