- #1
woofr_87
- 4
- 0
hye everyone...
i want to build a program where the program with a function that returns a pointer to the maximum value of an array of double. if the array is empty, the program should return NULL.
here is my code, but still have an error... every week i try to solve this problem but...hmmm.. I am new in programming...
can anyone assist me to solve my problem...
i want to build a program where the program with a function that returns a pointer to the maximum value of an array of double. if the array is empty, the program should return NULL.
here is my code, but still have an error... every week i try to solve this problem but...hmmm.. I am new in programming...
can anyone assist me to solve my problem...
PHP:
#include <stdio.h>
double* maximum(double* a, int size);
double* maximum(double* a, int size)
{
double max = 0;
int i;
if(a==NULL || a[i]==NULL)
{
printf("NULL");
}
else
{
for(i=0;i<size;i++)
{
if(a[i]>max)
{
max=a[i];
//ptr_max = &max;
//result2 = *ptr_max;
//result2 = max;
return max;
}
}
}
}
void main()
{
double array[4]={30.00,20.00,70.00,10.00};
//maximum(array,4);
// double result;
//result = maximum(array,4);
printf("The largest number is : %0.2f",maximum(array,4));
}