QUESTION 1: What is output by the following program?
|
|
QUESTION 2: Write a code segment that reads in an integer (call it num) and outputs the word "positive" if num is greater than zero, "zero" if num is equal to zero, or "negative" if num is less than zero.
QUESTION 3:What is output by the following (somewhat tricky) code segment?
|
|
QUESTION 4: Consider the following code segment.
|
|
At the point in the code labeled as an assertion, what must be true about the value of num?
QUESTION 5: What is output by the following code segment?
|
|
QUESTION 6: Rewrite the following while loop as a for loop.
|
|
QUESTION 7: Write a code segment that reads in a sequence of integers, terminated with a negative value, and outputs their sum. For example, if the user enters
QUESTION 8: Complete the function PrintReps whose header is given below:
QUESTION 9: What is output by the following program?
|
|
QUESTION 10: Suppose an array of doubles named values, size 100, has been declared and initialized. What would be the effect of executing the following code segment?
QUESTION 11: Suppose an array of doubles named values, size 100, has been declared and initialized. Write a segment of C++ code that would display the contents of the array in reverse order, one number per line of output. That is, the last number should be displayed on the first line, followed by the next-to-last number, and so on.
QUESTION 12: Complete the function SumElements whose header is given below: