## Prediction Exercises

These exercises will give you practice with an important skill; being able to comprehend a program well enough to predict the results of its execution.

#### Directions

1. For each problem, copy-and-paste the source code provided into a text editor (gedit, Notepad, nano, Vi, etc.)
2. Turn on line numbering
With gedit, from the Edit menu, choose "Preferences" and then "Display line numbers"
With vi,          :set number
3. Using college ruled binder paper, draw (not typewritten) a hand trace of the execution using the input data provided.
(Each row of data represents the input values for a single execution.  If there are multiple rows, multiple executions are required and thus multiple traces).
4. The output column shows your prediction of what the program will produce.
5. Compile the program with compiler of your choice.
6. Execute the program and observe the results.
7. Compare the actual output to your predictions.
8. If the actual output is exactly as your predicted, draw a star next to the output column.
9. If there is a discrepancy, determine where you made a mistake. Be sure you understand how the program arrived at the actual results.  Write a brief description of your error and give a correct explanation of the program's operation.
10. Submit your hand written work.

 Problem Input Data Hwk 1 Ch2_1.c 50 32 -50 Ch2_2.c 1 2 3 2 2 3 2 4 5 Ch2_3.c 2 1 2 5 3 2 3 3 Ch2_4.c (none) (Optional) UPC.c 0 37000 00407 2 Ch7_1.c 8000 9000 Ch3_1.c 3 5 2 Ch3_2.c (none) Ch3_3.c 3 5 7 3 Ch4_1.c 25 6000 Ch4_2.c 7/4/07 4 Ch5_1.c (none) Ch5_2.c 5 Ch5_3.c 3 Ch5_5.c 3 8 2 0 Ch5_6.c 734 Ch5_7.c 10 Ch5_8.c 10 17 Ch5_9.c c55d30brbq Ch7_2.c (none) Ch7_3.c bg Te 5 none 6 Arrays 1 7 3 5 7 2 8 4 3 3 9 Arrays 2 7 3 5 7 2 8 4 3 3 9 Arrays 3 Arrays 4 7359 28489 7 Ch11_3.c 2 5 7 12 7 7 4 99