Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C++ Quiz 05/05/2023

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following is an example of a function in C++?

a)

if statement

b)

for loop

c)

switch case

d)

cout statement

2.

Which of the following is used to define a function in C++?

a)

def

b)

fun

c)

void

d)

int

3.

Which of the following is used to switch between different cases in C++?

a)

for loop

b)

while loop

c)

do while loop

d)

switch case

4.

Which of the following loops will execute at least once in C++?

a)

for loop

b)

while loop

c)

do while loop

d)

switch case

5.

Which of the following is used to comment a single line of code in C++?

a)

//comment

b)

/*comment

c)

*/comment

d)

#comment

6.

Which of the following is used to comment multiple lines of code in C++?

a)

//comment

b)

/*comment*/

c)

*/comment*/

d)

#comment

7.

Which of the following is used to declare a variable in C++?

a)

var

b)

val

c)

const

d)

int

8.

What is a function in C++?

a)

A block of code that can be executed repeatedly

b)

A variable that stores a value

c)

A keyword that marks the end of a statement

d)

A structure used for storing data

9.

What is the syntax for declaring a function in C++?

a)

function_name {arguments}

b)

function_name (arguments)

c)

function_name [arguments]

d)

function_name <arguments>

10.

Which logic gate returns true only if both inputs are true?

a)

AND gate

b)

OR gate

c)

NOT gate

d)

XOR gate

11.

What are arrays in C++?

a)

A set of statements that perform logical operations

b)

A type of loop

c)

A way of storing multiple values of the same data type

d)

A pointer

12.

What is the continue statement in C++?

a)

A statement that jumps to a specific line of code

b)

A statement that ends a loop early

c)

A statement that continues a loop with the next iteration

d)

A statement that defines a function

13.

What is a ternary operator in C++?

a)

A loop

b)

A conditional operator that takes three operands

c)

A pointer

d)

A switch case statement

14.

What are data types in C++?

a)

A set of statements that perform logical operations

b)

A set of statements that perform mathematical operations

c)

A set of rules for writing C++ code

d)

A way of classifying variables according to the type of data they store

15.

Which of the following is used to return a value from a function in C++?

a)

def

b)

fun

c)

void

d)

return

16.

Which of the following is used to initialize an array in C++?

a)

=

b)

:

c)

;

d)

{

17.

Which of the following is used to access an element in an array in C++?

a)

( )

b)

{ }

c)

[ ]

d)

/

18.

Which of the following is used to iterate through an array in C++?

a)

if statement

b)

for loop

c)

while loop

d)

switch case

19.

What is the purpose of a multi-dimensional array in C++?

a)

To store multiple values of different types

b)

To create a loop

c)

To perform a specific task

d)

To store multiple values in a table format

20.

Are constants values changeable?

a)

True

b)

False