Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Level 3 Questions

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following is a correct variable declaration in C++?

a)

int 3value;

b)

int value_3;

c)

float& value;

d)

string name = 123;

2.

What is the output of 10 % 3?

a)

3

b)

1

c)

0

d)

10

3.

Which operator is used for assignment in C++?

a)

==

b)

=

c)

:=

d)

=>

4.

What does the && operator do?

a)

Adds two numbers

b)

Checks OR condition

c)

Logical AND

d)

Ends the loop

5.

Which data type is used to store a single character?

a)

string

b)

char

c)

int

d)

float

6.

What is the output of if(5 > 3) cout << "Yes"; else cout << "No";

a)

No

b)

Error

c)

Yes

d)

Nothing

7.

Which of these is a comparison operator?

a)

+

b)

=

c)

!=

d)

&&

8.

What will this loop do? int i = 0; while(i < 5) { i++; }

a)

Run 4 times

b)

Run forever

c)

Run 5 times

d)

Error

9.

What will the following print? int x = 5; if(x % 2 == 0) cout << "Even"; else cout << "Odd";

a)

Even

b)

Odd

c)

5

d)

Error

10.

Which loop runs at least once, even if the condition is false?

a)

for

b)

while

c)

do-while

d)

None

11.

Which symbol is used to access array elements?

a)

()

b)

{}

c)

[]

d)

<>

12.

How do you declare a 2D array of integers with 5 rows and 3 columns?

a)

int arr(5)(3);

b)

int arr[3][5];

c)

int arr[5][3];

d)

int arr{5,3};

13.

What does continue do in a loop?

a)

Stops the loop completely

b)

Skips the rest of current iteration

c)

Repeats the last step

d)

Ends the program

14.

What does break do in a loop?

a)

Ends all loops

b)

Exits only the current iteration

c)

Exits the loop completely

d)

Starts loop again

15.

Which keyword is used to define a function in C++?

a)

def

b)

void

c)

function

d)

declare

16.

What is the index of the first element in an array?

a)

1

b)

0

c)

-1

d)

Depends on size

17.

What is the correct way to call this function? int sum(int a, int b);

a)

sum a b;

b)

sum(a + b);

c)

sum(3, 4);

d)

call sum 3, 4;

18.

Which loop is best when the number of iterations is known?

a)

while

b)

do-while

c)

for

d)

switch

19.

What will x += 2 do?

a)

x = x + 2

b)

x = 2

c)

Error

d)

x = 2 + x + 2

20.

What happens if you forget break in a switch case?

a)

It gives an error

b)

It exits the switch

c)

It executes the next case(s)

d)

Skips all

21.

What does return do inside a function?

a)

Repeats function

b)

Exits function and sends a value back

c)

Pauses function

d)

Skips all code

22.

If int arr[3] = {5, 10, 15};, what is arr[1]?

a)

5

b)

10

c)

15

d)

1

23.

Which of the following is a valid function definition?

a)

int sum(a, b)

b)

sum(int a, int b)

c)

int sum(int a, int b)

d)

def sum(a, b)

24.

Which symbol is used to end a statement in C++?

a)

:

b)

;

c)

.

d)

,

25.

In a for loop: for(int i = 0; i < 5; i++), how many times does the loop run?

a)

6

b)

4

c)

5

d)

0

26.

The while loop always runs at least once.

a)

True

b)

False

27.

Arrays in C++ start from index 0.

a)

True

b)

False

28.

continue exits the entire loop.

a)

False

b)

True

29.

The modulus operator % gives the remainder.

a)

True

b)

False

30.

Functions can be called before they are defined.

a)

False

b)

True