wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz #1

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

Who invented C++?

a)

Dennis Ritchie

b)

James Gosling

c)

Bjarne Stroustrup

d)

Guido van Rossum

2.

Select the valid IDENTIFIERS

a)

hello

b)

_

c)

1_2_3

d)

hello123

e)

Int

3.

Which of the following is a correct way to declare an integer variable in C++?

a)

int 1num;

b)

integer num;

c)

int num;

d)

int-number;

4.

What is the output of the given code?

a)

4

b)

5

c)

6

d)

Compilation Error

5.

Which of the following is not a valid C++ data type?

a)

string

b)

bool

c)

integer

d)

double

6.

Which loop will always execute its body at least once, regardless of the condition?

a)

for loop

b)

do-while loop

c)
  • while loop

d)

None of the above

7.

What is the purpose of the break statement in C++?

a)

To terminate the current loop or switch statement

b)

To terminate the program

c)

To skip the current iteration

d)

To restart the loop

8.

What will be the output of the given code?

a)

1 1 1 1 1

b)

1 2 3 4 5

c)

5 4 3 2 1

d)

Infinite loop

9.

What is the result of the following operation: 5 & 3?

a)

1

b)

3

c)

5

d)

7

10.

What is the result of 4 ^ 5?

a)

2

b)

0

c)

9

d)

1

11.

What will be the output of the given code snippet?

a)

x is between 3 and 10

b)

No output

c)

Compilation error

d)

x is less than 3

12.

In C++, how do you write an if condition that checks if a variable x is either 5 or 10?

a)

if (x == 5 && x == 10)

b)

if (x == 5 || x == 10)

c)

if (x = 5 || x = 10)

d)

if (x == 5 and x == 10)

13.

It is possible to nest if statements within other if statements in C++.

a)

True

b)

False

14.

The continue statement can be used in if conditions but cannot be used in loops.

a)

True

b)

False

15.

The ternary operator ? : is also known as the (a)   operator and is used for shorthand conditional expressions.

16.

Want more QUIZs in up-coming sessions?

a)

Yes

b)

No