Homework #2

Due: Sept. 17, 2004 (F)

Your assignment is to write a program to print a multiplication table from 0 x 0 to 9 x 9. The output of your program should look sometime like:

X | 0 1 2 3 4 5 6 7 8 9

-----|----------------------------------------------------

0 | 0 0 0 0 0 0 0 0 0 0

|

1 | 0 1 2 3 4 5 6 7 8 9

|

2 | 0 2 4 6 8 10 12 14 16 18

.

.

.

Hints:

1) the %5d in a printf statement will print the integer value using at least 5 spaces (that way the columns can line up neatly)

Again, use the Linux system to edit, compile, execute, and debug your programs.

The steps you need to follow for this lab are similar to the last lab.

  1. use some editor (nano, pico, vi, emacs, etc.) under Linux to type your program into a file named "pgm2.c". For example, use the command "namo pgm2.c"
  2. compile the program using the GNU C compiler by typing: gcc -o pgm2 pgm2.c

    (which puts the executable programming in the file called "pgm2")

  3. If you have syntax errors, the compiler will tell you a line number and some poorly worded indication of the cause for each error. While you still have errors, go back to step (1) to edit your program and then recompile. When you have no syntax errors, go on to step (4).
  4. execute your program sending the output to the screen by typing:

    "./pgm2" where the "./" indicates the pgm2 in the current directory.

  5. If your program does not give the expected results, think about your logic before going back to step (1) to fix your program. When thinking about your logic, I would recommend playing computer and hand tracking each statement like the computer would. Hopefully, this will expose your semantic errors.

To submit your assignment, click on the link at the bottom of the homework page for the course: http://www.cs.uni.edu/~fienup/cs036f04/homework/index.htm

You will need to

  1. log on to the submission system using your CNS account information
  2. select the "810:036, C++ Fienup" course
  3. select the radio button corresponding to lab being submitted
  4. enter the name of the file you wish to submit which needs to be accessable on the computer from which you are submitting