Lab 9: Practice with argc and argv

Due Thursday, March 26, by 9:00 AM


Unlike earlier labs, for lab 9, the solution will be a C program rather than a series of commands. The program should expect a series of numbers as arguments on the command line, and some flags which control what to do with them: The flag will be restricted in position on this lab, and must come before any of the arguments. Also, the two flags are mutually exclusive, so you can expect the user will only supply one of them. I installed the solution to this lab on isoptera as lab9_solution, so run it a few times and see how it works. Here are some examples:
seth@isoptera:~ $ lab9_solution 1 2 32 
35.000000
seth@isoptera:~ $ lab9_solution -m 1 2 32 
64.000000
seth@isoptera:~ $ lab9_solution -a 1 2 32 
11.666667
Turn in your lab by creating a file named "lab9.c" with no extension in your home directory, with permissions set so that only you can view the file. Substitute a c++ file extension if your lab will only compile with c++. This assignment is worth 35 points, 5 from correct naming and permissions, and 30 from working correctly. As a reminder, you can set the permissions correctly with this line:
chmod 600 lab9.c