void maximum(double *max, double x[])
{
int i;

for( i = 0; i<100; i++)
{
if(max < x[i])
max=x[i];
}
}

Why isnt this working
Im probrably missing one syntaz that i cant think of at the moment

Thank u

Recommended Answers

All 4 Replies

When you say double *max, the variable max contains the address. To print the value you have to write *max .

PS I hope you have malloced memory for max

int main();
{
    int x =10;
    int *p = &x;

   printf("%d\n",*p);           // This gives 10
   printf("%u\n",p);            // This gives an address

   return 0;
}

PS I hope you have malloced memory for max

Why? Can't you just create the variable using double max; and pass in the address?

@Walt
Yes this could be another way to do it

Thanks
i did this

void Grades (int *Acounter,int *Bcounter,int *Ccounter,int *Dcounter,int *Ecounter, double x[])
{

int A=0,B=0,C=0,D=0,E=0;
int i;
for(i = 0; i<100 ; i++)
{
if(x[i] >= 90 && x[i] <= 100)
A++;
else if (x[i] >= 80 && x[i] <= 90)
B++;
else if (x[i] >= 70 && x[i] <= 80)
C++;
else if (x[i] >= 60 && x[i] <= 70)
D++;
else if (x[i]<60)
E++;
}
*Acounter = A;
*Bcounter = B;
*Ccounter = C;
*Dcounter = D;
*Ecounter = E;
}

Thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.