Greeting
I'm trying to write a single function that returns the average value and stores the count of the elements greater than the average value
into the parameter named greater, as defined in the following prototype:
float over_Avg(int v[], int n, int *greater);
my code is the folowing
Code:
#include <stdio.h>
#include <stdlib.h>
float avgVect(int v[], int n,int *greater)
{
int i;int count=0;
int s=0;
float average;
greater=&count;
for(i=0;i<n;++i)
s=s+v[i];
average =s/n;
for(i=0;i<n;++i)
{
if (v[i]>average)
count++;
}
return average;
}
int main ()
{
int v[] ={1,0,3};
int *ptr;
float resul;
resul= avgVect(v,3,ptr);
printf("%f %d",resul,(*ptr));
}
and as you might have understood it's not working so what's wrong?
any hint would be highly appreciated!!
Best