Home | | Schedule | | Assignments | | Lectures | | Resources
Lab 4 Grade Sheet (25 points)
Loops
Question 1 How does the program output differ from that described in the program comments.
The last loop is said to go from 0 to 1 in increments of 0.1, however, it goes from 0 to 0.9 in increments of 0.1.
Question 2 How can you tell the difference between the output of the disp statement in the debugger and the output of the program that is printed in the debugging window.
Output of the program is always just displayed on the screen whereas the output of a disp statement is always preceeded by a number followed by a colon.
Question 3 Continue to step through the code for the first for loop. List all the values that i takes on within the body of the for loop. In other words, what values of i cause the statements between the braces to be executed?
1, 2, 3, 4, 5
Question 4 Why do we not include the value of 6 as a value that i takes on within the body of the loop? Why does the debugger display 6 as a value of i?
At the end of the 5th loop, i is incremented to 6. Then, the expression, i < 6, is evaluated, and since it is false, the loop is broken. The debugger then moves on past the loop.
Question 5 List all the values ch takes on within the body of the for loop. You will need to display the value of the variable ch.
65 A, 66 B, 67 C, 68 D, 69 E
Question 6 List all the values r takes on within the body of the for loop.
0, 0.10000001, 0.200000003, 0.300000012, 0.400000006, 0.5, 0.600000024, 0.700000048, 0.800000072. 0.900000045
Question 7 Explain why the third for loop does not print the value 1.0.
Because r = 1.00000012 which is greater than 1
forerr.cc
Source code for forerr.cclotto.cc
Source code for lotto.ccsquare.c
Source code for square.c
Home | | Schedule | | Assignments | | Lectures | | Resources
CSCI 131: Techniques of Programming
Last Modified: February 23, 2014
Page Expires: October 12, 2014