Lab 9: Practice with argc and argv

Due Thursday, April 7, by 9:00 AM


Unlike earlier labs, for lab 9, the solution will be a C (or C++) program rather than a series of commands. We'll have labs on C for a couple weeks, but come back to practice commands starting around lab 11 or so. 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 10 10 30 25 25
100.000000
seth@isoptera:~ $ lab9_solution -m 1 2 32 
64.000000
seth@isoptera:~ $ lab9_solution -a 1 2 3 4 5 6 7
4.000000
Turn in your lab by creating a file named "lab9.c" or "lab9.cpp" with no extension in your home directory, with permissions set so that only you can view the file. Use 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