Assignment #1

Due date: July 3, 2008. Email me a tarball or ZIP file containing your source code and any text files you want to include. Comment your source code thoroughly so that you (and I) know what's going on. I will return your assignment to you with comments and a grade (not an “official” grade) by July 10, 2008. Feel free to email me with any questions.

I recommend against using Google or your labmates as resources; try to do this assignment by yourself.
  1. Write a program called fact.c that computes the factorial of some number. You should have a function called factorial that takes one integer parameter. Your function should return an integer or a long integer. Test your program with some small integer arguments. (What happens if the integer argument is too large?) You can hard-code the number to be operated upon (easy), or you can accept it as input on the command line (tricky, at least until Part 2).
  2. Write a program called reverse.c that takes three command-line arguments and prints them in reverse order.
  3. Find the C source code for any popular UNIX tool (hint: here's Solaris) and explain in English—preferably in just a few paragraphs—what it does.