#include <stdio.h>
#include <stdlib.h>
double average(int arrx[6], int *ptr);
int main(void){
int arry[6]= {2,5,4,5,6,7};
int count=0;
double avg;
avg=average(arry,&count);
printf("The average is %.2f\n",avg);
printf("Number bigger than average is %i", count);
return 0;
}
double average(int arrx[6], int *ptr){
int c=0;
int sum=0;
double a=0;
for(c=0;c<6;c++){
sum=(double)sum+arrx[c];
}
a=sum/6;
for(c=0;c<6;c++){
if(arrx[c]>a){
*ptr = *ptr+1;
}
}
return a,*ptr;
}
The the program is working but shows wrong answer in average. it should be 4.83 but the program shows 4.00. there is no problem on number bigger than average, it is showing the correct answer. i think i done something wrong on my function and return value or the function. anyone can help me with this?