CS262 Lab 5 – Debugging
Question / Answer Sheet

Student Name ________________                                               G Number ______________

Lab TA ______________________                                             Lab Section _______________

The questions on this sheet should be answered as you progress through Lab 5. They are given in the original order of the main Lab 5 document. Use the original documentation for Lab 5, but write the answers to the questions on this sheet.

It is important that you follow this narrative carefully, and avoid any shortcuts in this lab. The answers to many of the questions you will be given depend upon properly completing the lab in the sequence presented.

Note: This lab must be completed on mason using the cc compiler. The gnu compiler or compilers on other systems (Microsoft Visual C++ or XCode) may not give the same results. The TA will be looking for specific answers for the grading of this lab and the use of other compilers may result in incorrect answers.

Step #1:

How many errors appear? ___
How many warnings appear?____

Step #2:


Step #3:

Run the program, and at the prompt, enter the value 10.
What happens? _____________________________________

What value is printed after “The sum of integers 0 to 10 is: “ ? ______
What value *should* have been printed? ______

Step #4:

How many times does the printf statement you added get executed? _____
List in order the values output by the printf statement you added: ___________________

Answer the following questions again, based on the most recent code execution:
How many times does the printf statement you added get executed? ___________
List the values output by the printf statement you added: ____________________
What is the value of sum output by the program in the final statement? ________

Compile and run the code again (using 10 as input). Did the warning message go away? _______

Now answer the following questions:
How many times does the printf statement you added get executed? _____
List the values output by the printf statement you added: ____________________
What is the value of sum output by the program in the final statement? ________

Comment out the for loop, and copy it to the line below, this time without the semicolon.
Compile and run the program again (using 10 as input). Now answer the questions:
How many times does the printf statement you added get executed? _____
List the values output by the printf statement you added: ____________________
What is the value of sum output by the program in the final statement? ________
Is the final value of sum correct? (Look at your answer to step #3 above) _________

You are supposed to add the integers from 0 to 10. Which integer is missing? ________

Compile and run the code again (using 10 as input):
Answer the following questions:
How many times does the printf statement you added get executed? _____
List the values output by the printf statement you added: ____________________
What is the value of sum output by the program in the final statement? ________

Step #5:
Recompile, and run the code. Has the output changed? ______________________

Step #6: Turn in the following to your TA =>
  1. A hard copy of your revised file lab5.c containing the changes you made throughout the course of this lab.
  2. A hard copy of your completed lab 5 question/answer sheet.

*** YOU ARE DONE!!! ***