Sie sind auf Seite 1von 3

CS222 Assignment 4 – Debugging

Question / Answer Sheet

Student Name _Priyam Das_______________ G Number


_00952946_____________

The questions on this sheet should be answered as you progress through Assignment
4. They are given in the original order of the main Assignment 4 document. Use the
original documentation for Assignment 4, 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 assignment. The answers to many of the questions you will be given depend
upon properly completing the assignment in the sequence presented.

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

Step #1:
How many errors appear? _17__
How many warnings appear?__4__

Step #2:

Step #3:
Run the program, and at the prompt, enter the value 10.
What happens? __After entering 10, it only rolls once and then just stops
abruptly. ___________________________________

How many times did the program roll the dice? __01____
How many times did you anticipate the program to roll? _10_____

Step #4:
How many times does the printf statement you added get executed? __01___
List the values output by the printf statement you added: _______10____________
Compile and run the code again (using 10 as input). Did the warning message go
away? ____yes___

Now answer the following questions:


How many times does the printf statement you added get executed? __01___
List the values output by the printf statement you added:
________10____________

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? __09___
List the values output by the printf statement you added:
_1,2,3,4,5,6,7,8,9___________________

How many times have you been rolling the dice? ____09____________

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? __10___
List the values output by the printf statement you added:
__1,2,3,4,5,6,7,8,9,10__________________

Step #5:
Answer the following questions:
How many times does the printf statement you added get executed? __11___
List the values output by the printf statement you added:
__0,1,2,3,4,5,6,7,8,9,10__________________

Change back to i=1, and recompile, and run the code. Answer the following questions:

How many times does the printf statement you added get executed? _10____
List the values output by the printf statement you added:
__1,2,3,4,5,6,7,8,9,10__________________

Step #6:

List the function calls and their corresponding include files other than main and
return: 1) srandom((unsigned int)(time(NULL))); include file: <time.h>
2) printf; include file: <stdio.h>

3) scanf; include file: <stdio.h>

4) random(); include file: <stdlib.h>

5) system; include file: <stdio.h>

Briefly explain what does the program do: The program generates a sequence of random
numbers from 1 to 6 by rolling a dice.

Step #7: Submit the following on Blackboard as HW4 =>


1. A soft copy of your revised file hw4.c containing the changes you made throughout the
course of this assignment.
2. A soft copy of your completed assignment 4 question/answer sheet.

Das könnte Ihnen auch gefallen