Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C++ Mastery Challenge

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

What is the purpose of a loop in C++?

a)

The purpose of a loop in C++ is to repeatedly execute a block of code until a certain condition is met.

b)

To play music

c)

To send emails

d)

To cook dinner

2.

How do you write a for loop in C++?

a)

for(int i; i < n; i++) { // code block }

b)

for(init; cond; update) { // code block }

c)

for(initialization; condition; update) { // code block to be executed }

d)

for(int i = 0; i < n; i++) { // code block }

3.

What are conditional statements in C++?

a)

Conditional statements in C++ are used for defining functions

b)

Conditional statements in C++ are used for declaring variables

c)

Conditional statements in C++ are used to execute different code based on certain conditions.

d)

Conditional statements in C++ are used for loop control

4.

How do you use if-else statements in C++?

a)

if-else statements are used for defining functions in C++

b)

The if-else statements in C++ are used to make decisions based on conditions.

c)

if-else statements are used for looping in C++

d)

if-else statements are used for printing output in C++

5.

What is the significance of input and output operations in C++?

a)

Input and output operations in C++ are only used for debugging purposes.

b)

Input and output operations in C++ have no impact on the functionality of the program.

c)

Input and output operations in C++ are optional and can be omitted.

d)

Input and output operations in C++ are essential for interacting with users and external devices.

6.

How do you read user input in C++?

a)

Using 'gets' function

b)

Using 'cout' and '<<' operator

c)

Using 'scanf' function

d)

Using 'cin' and '>>' operator

7.

Explain the concept of functions in C++.

a)

Functions in C++ do not allow for code reusability.

b)

Functions in C++ are used for styling purposes only.

c)

Functions in C++ cannot accept input parameters.

d)

Functions in C++ are blocks of code that perform a specific task. They allow for code reusability

8.

How do you declare an array in C++?

a)

int myArray[5];

b)

array myArray[5];

c)

int myArray();

d)

myArray = new int[5];

9.

How do you access elements in an array in C++?

a)

arr.index

b)

arr{index}

c)

arr[index]

d)

arr(index)

10.

What is the syntax for iterating over an array in C++?

a)

for(int i = 1; i <= arraySize; i++) { // access array elements using array[i] }

b)

for(int i = 0; i < arraySize; i++) { // access array elements using array[i] }

c)

for(int i = arraySize - 1; i >= 0; i--) { // access array elements using array[i] }

d)

for(int i = 0; i <= arraySize; i++) { // access array elements using array[i] }

11.

What is the role of arrays in data structures?

a)

Arrays can only store one type of data

b)

Arrays cannot be resized once created

c)

Arrays store a collection of elements in a contiguous memory location and provide efficient random access based on index.

d)

Arrays do not support efficient random access

12.

What are the advantages of using arrays in C++?

a)

Arrays in C++ are slow and inefficient for memory usage

b)

Arrays in C++ provide storing multiple elements of the samedata type in contiguous memory.

c)

Arrays in C++ can only store elements of different data types

d)

Arrays in C++ do not allow easy element access