Due Date: Wednesday, December 13 by midnight
NO LATE PROJECTS WILL BE ACCEPTED!
Point Value
This assignment is worth 50 points.
Objectives
This assignment is very similar to Project 2. But this time, you will be reading the student ages into an array and then producing statistics, rather than processing the ages one at a time. You will also be dividing your program into functions. The code for the main function will be supplied (see below). You will need to write the code for the remaining eight functions, their prototypes, and any necessary preprocessor directives (note that this program has two defined constants, AGE and NRSTUDENTS).
Assignment
You have been assigned the task of producing statistics based on the ages of all current CMSC 104 students. Given the ages, you are to determine each of the following pieces of information:
Name the program proj4.c. Use #define preprocessor directives to define the constant AGE as 19 and the constant NRSTUDENTS as 50. A data file containing the ages for you to use as input to your program will be provided. (These ages are obviously not from a survey of all CMSC 104 students because there are too few ages in the file.) You may assume that there is at least one age and no more than 50 ages in the file. The ages, which can be assumed to be positive, non-zero numbers, are in random order. The last value in the file is -1. This is the sentinel value that signals the program to stop reading ages.
To use the data file as input to your program, you will use UNIX redirection.
By using redirection, you can have UNIX fill the stdin
buffer
from a data file rather than from the keyboard. The scanf
statement that you use in your program will look exactly the same as it would
if you were getting your input from the keyboard. Since you will be
getting the values from a file instead of from a user typing at the keyboard,
you will not need to prompt the user.
When you run your program, use the following command:
Here is an example of what a data file might look like:
Here is the output that would result from using this sample data file:
Your program's output should follow this EXACT format.
Main Function
Here is the main function EXACTLY as it should appear in your program. Do NOT alter it IN ANY WAY. (You can simply "cut and paste" the function from this page into your text editor.)
Coding Standards and Indentation
Make sure that you follow the "C Coding Standards" and "Indentation Styles" given on the Projects web page. Your program will be graded not only on whether or not it produces the correct results, but also on whether or not you follow these standards and styles.
Compiling Your Project
Recall that you must compile and run your program on linux. To compile your program, execute the command
Project Submission
Submit your project by e-mailing your source code (proj4.c) to Jason (cai1@gl.umbc.edu) as an attachment. Make the Subject of the e-mail Project 4 so that Jason knows what it is. Do NOT send your executable file (a.out).