Hi,
that should be fairly easy. You just use a
while loop to go through the arroy and when you find zero, the loop ends:
#include <stdlib.h>
#include <stdlio.h>
#include <limits.h>
void FindMinAndMax(int* array, int length)
{
int Min = INT_MAX;
int Max = INT_MIN;
if (array[length-1] != 0)
{
printf("Error: Array must end with 0 !!!");
return ;
}
int i = 0;
while (array[i] != 0)
{
if (array[i] > Max)
Max = array[i];
if (array[i] < Min)
Min = array[i];
i++;
}
printf("Min = %d\n", Min);
printf("Max = %d\n", Max);
}
Hope this helps.
Best regards.
J.K.