I am trying to create a program that gets the min and max of a list. I so far have this but when I run the program and put in a list i get the max, but the min is 0 because you have to end it with zero. How do i have that the 0 is not in the list.
#include <iostream>
#include <stdio.h>
#include "simpio.h"
#include "strlib.h"
#include "random.h"
using namespace std;
int main()
{
int n, min, max;
printf("Please enter a list of integers.\nSignal the end of your list with 0.\n");
printf("Enter first number: ");
n = GetInteger();
if (n==0){
printf("You did not enter any numbers.");
}else{
min = n;
max = n;
while (n!=0)
{
printf("Enter next number: ");
n = GetInteger();
if ( n <= min ) min = n;
if (n >= max) max = n;
}
printf("The maximum number in the list is %d.\n", max);
printf("The minimum number in the list is %d.\n", min);
system("pause");
}
}