Programming Quiz

  • Question 1

5 out of 5 points

What will the following code print?
Selected Answer:  5 6 4
  • Question 2

5 out of 5 points

The C++ ________ operator represents logical AND.
Selected Answer: &&
  • Question 3

5 out of 5 points

Relational operators allow you to ________ numbers.
Selected Answer: compare
  • Question 4

5 out of 5 points

In a for statement, the ________ expression is executed only once.
Selected Answer: initialization
  • Question 5

0 out of 5 points

A for statement contains three expressions: initialization, test, and
Selected Answer: increment.
  • Question 6

5 out of 5 points

True/False: Assuming goodData is a Boolean variable, the following two tests are logically equivalent.
Selected Answer: True
  • Question 7

5 out of 5 points

True/False: The following C++ test checks if the variable child is in the range 3-12.
Selected Answer: False
  • Question 8

5 out of 5 points

A trailing else placed at the end of an if/else if statement provides a default action when ________ of the if conditions is/are true.
Selected Answer: none
  • Question 9

5 out of 5 points

The ideal type of loop to use for repeating a menu is a(n) ________ loop.
Selected Answer: do-while
  • Question 10

5 out of 5 points

In C++ when a relational expression is false, it has the value
Selected Answer: 0.
  • Question 11

5 out of 5 points

What will the following code print?
Selected Answer:  7 7 8
  • Question 12

5 out of 5 points

True/False: To check if a variable has a particular value, use the = relational operator, as in the statement
Selected Answer: False
  • Question 13

5 out of 5 points

True/False: The statement
Selected Answer: True
  • Question 14

5 out of 5 points

The ________ operator takes an operand and reverses its truth or falsehood.
Selected Answer: !
  • Question 15

5 out of 5 points

If a switch statement has no ________ statements, the program “falls through” all of the statements below the one with the matching case expression.
Selected Answer: break
  • Question 16

5 out of 5 points

The ________ statement causes other program statements to execute only under certain conditions.
Selected Answer: if
  • Question 17

5 out of 5 points

True/False: When a loop is nested inside another loop, the inner loop goes through all its iterations for each iteration of the outer loop.
Selected Answer: True
  • Question 18

8 out of 10 points

Using a loop, write the needed statements to print out the even numbers from 1 through 100.

The expected output should be:

2, 4, 6, 8, …, 96, 98, 100

Selected Answer: for ( int i = 0 ; i <= 100 ; i++ )

{

if ( i % 2 == 0 )

{

cout <<i <<“,”;

}

}

Response Feedback: There should be no comma at the end (-2 points)
  • Question 19

5 out of 5 points

The ++ operator
Selected Answer: All of these.