csci 20 :: book learning challenge 4 (due tues, feb 16)
Submitting your work:

Complete this exercise on your own.

(1) Fill in all of the "Answer" boxes, (2) press "Prepare for printing", then (3) print the answer grid.

Staple all pages together and submit to the instructor on the date listed above.

Questions:

Read Operators, Operators, Arithmetic operators, Compound assignment, Type conversion and answer the following:

Your name:
  1. Replace the C++ statement below with a statement using compound assignment that yields the same result (assume x has already been properly declared and initialized as an integer variable):
    x = x + 5;
    Answer:
  2. Replace the C++ statement below with a statement using compound assignment that yields the same result (assume x has already been properly declared and initialized as an integer variable):
    x = x - 5;
    Answer:
  3. Replace the C++ statement below with a statement using compound assignment that yields the same result (assume x has already been properly declared and initialized as an integer variable):
    x = x * 5;
    Answer:
  4. Replace the C++ statement below with a statement using compound assignment that yields the same result (assume x has already been properly declared and initialized as an integer variable):
    x = x / 5;
    Answer:
  5. Replace the C++ statement below with a statement using compound assignment that yields the same result (assume x has already been properly declared and initialized as an integer variable):
    x = x % 5;
    Answer:
  6. What is the output of the following C++ code?
    int num1 = 29;
    int num2 = 7;
    cout << (num1 / num2) << endl;
    Answer:
  7. What is the output of the following C++ code?
    int num1 = 71;
    int num2 = 9;
    cout << (num1 % num2) << endl;
    Answer:
  8. What is the output of the following C++ code?
    int num1 = 10;
    int num2 = 20;
    cout << (num1 / static_cast<double>(num2)) << endl;
    Answer:
  9. Write a single C++ statement that will output 0 (zero) if the value of the integer variable x is an even number.
    Answer:
  10. Write the four (4) C++ statements that can be used to increment the value of the integer variable x by 1.
    Answer:

Total points for this book learning challenge:

150 points