CS C++
Quiz 1
  1. What is the value of the integer expression: 1 - 3 * 5 + 6 / 4 % 2
    (a) 0
    (b) -8
    (c) -13
    (d) -15

  2. If addition had higher precedence than multiplication, then the value of the expression
    1 + 2 * 3 + 4 * 5
    would be which of the following?

    (a) 65
    (b) 69
    (c) 105
    (d) 135

  3. True or false: The expressions a + b % c and (a + b) % c are equivalent.

  4. True or false: The expressions a - b + c and (a - b) + c are equivalent.

  5. The value of the expression 19 / 8.0
    (a) has type double and value 2.375
    (b) has type double and value 2
    (c) has type int and value 2
    (d) has type int and value 2.375

  6. Write down (line by line) the output of the following program:
    #include <iostream.h>
    
    int main()
    {
      int a, b;
    
      a = 6;
      b = a + 7;
      cout << "a = " << a << ", b = " << b << endl;
    
      a += b / 3;
      cout << "a = " << a << ", b = " << b << endl;
    
      a = b = 2 * a;
      cout << "a = " << a << ", b = " << b << endl;
    }