I'd like to ask why my code doesn't work I've tired many more things to no avail for some peculiar reason the program can find the minimum value of the array but cannot find the minimum value of it and returns the value 0.000000. Hope the code below helps.
This is what I have on my main function.
int main(void){
float array[5] = {12,32,56,67,54};
float min;
float max;
float *ptrMin;
float *ptrMax;
ptrMin = &min;
ptrMax = &max;
findMinMax(array, ptrMin, ptrMax);
printf("%f %f", *ptrMin, *ptrMax);
system("pause");
return 0;
}
I use the function findMinMax to return TWO values back to my main function.
void findMinMax(float *array, float *ptrMin, float *ptrMax){
float ptrMinTemp;
float ptrMaxTemp;
*ptrMin = ptrMinTemp;
*ptrMax = ptrMaxTemp;
while(*array){
if(*array < ptrMinTemp){
ptrMinTemp = *array;
*ptrMin = ptrMinTemp;
}
if(*array > ptrMaxTemp){
ptrMaxTemp = *array;
*ptrMax = ptrMaxTemp;
}
array++;
}
}
Before adding this comment , yes I created the prototype function and also included the correct header files.
#include <stdio.h>
#include <stdlib.h>
void findMinMax(float *array, float *ptrMin, float *ptrMax);
In the console I get the following:
0.000000 67.000000Press any key to continue . . .