Question
July 30, 2009 at 09:04 AM
kbikkasani

max and min of a list with sentenial at 0

by kbikkasani . Updated 17 years, 1 month ago

Im having trouble with the smoothness of running this program. If you run it you will see the program right away. The program completes the task but uses a GetInteger function unnecessarily in the third line. Any help would be appreciated.

Here is the program

#include
#include “simpio.h”
#include “genlib.h”

int main()
{
int n, min, max;

printf(“Please enter a list of integers.\n”);
printf(“Signal the end of your list with 0.\n”);
printf(“Enter first number: “);
n=GetInteger();
{
min=n;
max=n;
while ((n=GetInteger())!=0)
{
printf(“Enter next number: “);
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);
}
}

This discussion is locked

All Comments