I explain this method by a simple example. The user first enters the number n of integers, and then the integers themselves. The program stores these integers in an array. Then, the user supplies whether average (a), minimum (m) or maximum (M) is to be computed. Based upon the user's response, the program performs the requested work.
Here is a simple-program to do this: simple.c.
Some inputs for this program are given in the files: input1.txt | input2.txt | input3.txt
instead of entering these data manually, let the data be redirected from the files. Compile your program, and run as follows. See what happens.
$ gcc -Wall -o simple simple.c $ ./simple < input1.txt $ ./simple < input2.txt $ ./simple < input3.txt