I'm trying to make a simple program which outputs the maximum value and minimum value from the user's input.
But it always takes one more input than I intend.
It seems to have a problem with scanf() but I'm not really sure.
int num, max = -100000, min = 1000000;
scanf("%d", &num);
int array[num];
for (int i = 0; i < num; i++) {
scanf("%d ", &array[i]);
if (max < array[i])
max = array[i];
if (min > array[i])
min = array[i];
}
printf("%d %d", max, min);