Selected Midterm Questions

1. Which of the following is a valid identifier?

  1. big-number
  2. 50Percent
  3. double
  4. $SalesTax

More information: Lesson 2.1.3

2. What is the value of degreesC after the following statements execute?

double degreesC, degreesF;
degreesF = 122;
degreesC = 5 / 9 * (degreesF - 32);
  1. 0
  2. 0.0
  3. 50
  4. 50.0

More information: Lesson 2.3.3

3. What is the value of the following expression?

(true && (4 / 3 || !(6)))
  1. true
  2. false
  3. 0
  4. illegal syntax

More information: Lesson 4.1

4. What is the value of the following expression?

(false || (!(4 / 3) && !(6)))
  1. true
  2. false
  3. 0
  4. illegal syntax

More information: Lesson 4.1

5. What is the output from the following loop:

int i = 10;
while (i >= 0)
    cout << i << endl;
    i--;
  1. No output
  2. The number 10 will be output infinitely
  3. The number 10 will be output exactly one time
  4. The numbers 0 through 10 will be output

More information: Lesson 4.4.4