wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

TEB2132 Lecture 3 Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which one is NOT a control structure in C++?

a)

Sequence

b)

Repetition

c)

Execution

d)

Selection

2.

What is the type of operator != in C++?

a)

relational

b)

equality

c)

logical

d)

expression

3.

A logical expression && returns 1 (true) if

a)

Both operands are 1 (true)

b)

Both operands are 0 (false)

c)

One operand is 1 (true)

d)

One operand is 0 (false)

4.

Which operator is commonly used in an if condition to check equality in C++?

a)

=

b)

!=

c)

===

d)

==

5.

Which keyword is used to exit a switch case immediately after executing a statement?

a)

exit

b)

break

c)

stop

d)

return

6.

What will happen if the break statement is omitted in a switch case?

a)

Program ends immediately

b)

Only the current case runs

c)

Execution continues into the next case

d)

Compilation error

7.

Which of the following data types can be used in a switch statement in C++?

a)

bool

b)

char

c)

float

d)

double

8.

Which statement is true about if–else and switch?

a)

if–else is used for range-based conditions, while switch works with discrete values.

b)

switch can handle conditions with < or >.

c)

Both can only be used with integers.

d)

Both are identical in functionality.

9.

What is the default block in a switch statement used for?

a)

To terminate the program

b)

To execute all cases together

c)

To execute if no case matches

d)

To initialize variables

10.

Find the output:

char ch = 'b';

switch (ch) {

    case 'a': cout << "Apple"; break;

    case 'b': cout << "Ball"; break;

    case 'c': cout << "Cat"; break;

    default: cout << "None";

}

a)

Apple

b)

Ball

c)

Cat

d)

None