First bug spotted: min and max could reflect outside of array values.

Let's try with this:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX_VALUE 1000
#define ARR_LEN 99
int main(void)
{
int array[ARR_LEN];
int min, max;
int cnt_min = 1, cnt_max = 1;
srand (time(NULL));
do {
min = rand() % MAX_VALUE;
max = rand() % MAX_VALUE;
} while (min >= max);
array[0] = min;
array[1] = max;
printf("array[0] is %d\n", array[0]);
printf("array[1] is %d\n", array[1]);
for (int i = 2; i < ARR_LEN; ++i) {
array[i]=rand() % MAX_VALUE;
printf("array[%d] is %d\n",i,array[i]);
if (array[i] == min) {
++cnt_min;
} else if (array[i] == max) {
++cnt_max;
} else if (array[i] > max) {
max = array[i];
cnt_max = 1;
} else if (array[i] < min) {
min = array[i];
cnt_min = 1;
}
}
printf("\n\nMaximum is %d\n", max);
printf("Minimum is %d\n", min);
printf("cnt_min = %d\n", cnt_min);
printf("cnt_max = %d\n", cnt_max);
return 0;
}