Hello. I am new to the forum but I hope i'll be very active since i'm starting with my programming classes and i'll need all the help I can get

Anyway I have this project:

Write a project that reads in five integers and then determines and prints the largest and the smallest integers in the group. The program must readthe data from an external file and print the results to another external file.USE LOOPING.

And here's what I came up with

Code:#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int a, b, c, d, e, smallest, largest; FILE *numbers; FILE *results; numbers = fopen("data.txt","r"); results = fopen ("results.txt","w"); fscanf(numbers, "%d %d %d %d %d", &a, &b, &c, &d, &e ); smallest = a; if (b < smallest) smallest = b; if (c < smallest) smallest = c; if (d < smallest) smallest = d; if (e < smallest) smallest = e; fprintf ( results, "smallest is %d\n", smallest); largest = a; if (b > largest) largest = b; if (c >largest) largest = c; if (d >largest) largest = d; if (e > largest) largest = e; fprintf ( results, "largest is %d\n", largest); while ( fscanf (numbers, "%d", &a, &b, &c, &d, &e)!= EOF ) fclose(results); fclose(numbers); return 0; }

The problem is that when I conferred with the prof. he said that it was fine and dandy but then he asked(with an evil grin(BASTAGE THAT HE IS BTW )) :

What if you had 5millionintegers to sort out? Would you want to write 5 million "ifs"? I want only ONE if for the smallest and only ONE if for the largest for the program to sort the integers out into smallest and largest.

So thats my problem, I can't for the life of me come up with a looping set of code that uses only ONE if to sort the integers into largest and smallest.

ANY help will be greatly appreciated.