I am trying to right code for an assignment I have, which is to take an infinite number of integers and then display the minimum and maximum number. With my code in the output screen it says that the minimum and maximum numbers are both 0.
Here's what i have:
Code:
#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
main()
{
int min, max, num;
printf ("This will compute the minimum and maximum number in the list. Signal the end of the list with 0.\n");
printf ("Enter your first number: ");
num = GetInteger();
min = 0;
max = 0;
while (num!=0)
{
if (num < min)
num = min;
else if (num > max)
num = max;
else num = num;
printf ("Enter your next number: ");
num = GetInteger();
}
printf ("The maximum number in the list is %d.\n", max);
printf ("The minimum number in the list is %d.\n", min);
getchar();
}