Runescapian321
01-06-2008, 11:49 PM
I need to make a C program that finds the lowest and max of an undefined amount of numbers. Yeah, I know, that's kind of confusing, once I show you the program you'll get it, think it's easy, and then it's confusing all over again (that's what I went through anyways :p). So here is what I have so far
#include "stdafx.h"
#include "simpio.h"
#include "genlib.h"
int main()
{
int num, num1;
printf("Please enter a list of integers.\n");
printf("Signal the end of your list with 0.\n");
printf("Enter the first number: ");
num = GetInteger();
num1 = 0;
while(num!=0)
{
printf("Enter the next number: ");
num = GetInteger();
if (num > num1)
num1 = num;
if (num1 >= num)
num1 = num1;
}
printf("The biggest number is %d\n", num1);
}
(made it in Scar tags so it would be easier to read, just disregard the green)
I got the biggest number, but I can't for the life of me figure out how to get the lowest one...It seems like it should be simple, but I've been tearing my hair out trying to figure it out for almost an hour...Any help anyone?
#include "stdafx.h"
#include "simpio.h"
#include "genlib.h"
int main()
{
int num, num1;
printf("Please enter a list of integers.\n");
printf("Signal the end of your list with 0.\n");
printf("Enter the first number: ");
num = GetInteger();
num1 = 0;
while(num!=0)
{
printf("Enter the next number: ");
num = GetInteger();
if (num > num1)
num1 = num;
if (num1 >= num)
num1 = num1;
}
printf("The biggest number is %d\n", num1);
}
(made it in Scar tags so it would be easier to read, just disregard the green)
I got the biggest number, but I can't for the life of me figure out how to get the lowest one...It seems like it should be simple, but I've been tearing my hair out trying to figure it out for almost an hour...Any help anyone?