wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C++ Programming Quiz sesi (ii) 2023/2024

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Identify THREE (3) types of error in programming.

a)

Grammatical error, single time error, logical error

b)

Syntax error, run-time error, logical error

c)

Syntax error, mathematical error, single error

d)

Grammatical error, calculation error, logic error

2.

Identify the CORRECT answer to represent the statement shown in Figure A2.

a)

Identifiers

b)

Variable

c)

Constant Variable

d)

Data Types

3.

Identify the acceptable ways to define variables.

a)

int a; b;

b)

int a, int b;

c)

int a; double b;

d)

int a, double b;

4.

Identify the suitable symbol that is used for initialization in Programming.

a)

;

b)

_

c)

<< 

d)

=

5.

Choose the CORRECT C++ syntax to declare a variable named “Address” of string type.

a)

char Address;

b)

char Address (20);

c)

string address;

d)

string address (20);

6.

Choose the suitable answer for a variable based on the given statement.

a)

Local variable

b)

Global Variable

c)

Function Variable

d)

Class Variable

7.

Trace the output of the given C++ program in Figure A7.

a)

4, 3, 3, 1

b)

4, 3, 3, 0

c)

4,

3,

3,

0

d)

4,

3,

3,

1

8.

Which of the following is used for input in C++?

a)

cout

b)

cin

c)

printf

d)

scanf

9.

Identify the answer that is NOT related to a looping control structure.

a)

for

b)

while

c)

do

d)

do..while

10.

Identify the number of repetitions in Figure A10.

a)

18

b)

19

c)

20

d)

21

11.

Choose the correct C++ statement to print a message 12 times.

a)

for (int count = 1; count <= 11; count++)

b)

for (int count = 1; count < 11; count++)

c)

for (int count = 2; count < 11; count++)

d)

for (int count = 0; count <= 11; count++)

12.

Given the following code, identify the value of 'y' after execution.

a)

0

b)

1

c)

2

d)

3

13.

Determine the output based on the given C++ program.

a)

3 5 7 9 11

b)

1 3 5 7 9

c)

3 6 8 9 10

d)

1 3 6 9 11

14.

What happens if a break statement is omitted in a switch case?

a)

The next case executes

b)

The program crashes

c)

Only the first case executes

d)

An error occurs

15.

Select the CORRECT answer to explain arrays.

a)

It saves storage space storing under one name

b)

Able to store things related to different topics

c)

Can store integers and strings together

d)

Group of memory locations with the same name and type

16.

Identify elements in the following array in Figure A16 below.

a)

14

b)

13

c)

15

d)

12

17.

Choose the correct structure declaration from Figure A17.

a)

struct CDCollection

{float Price;}

RockNRoll;

b)

struct CDCollection

{float Price;}

RockNRoll;

c)

struct RockNRoll

{float Price;}

CDCollection;

d)

struct Price

{float RockNRoll;}

CDCollection;

18.

Determine the output for Figure A18.

a)

6 2 3 4 1 5

b)

5 1 4 3 2 6

c)

6 2 3 4 1 5

d)

6 2 3 4 1 5

19.

Determine the output for Figure A19.

a)

23 18

b)

33 28

c)

33 5

d)

23 5

20.

Choose the statement to display the value of 'Age'.

a)

cout<<&pAge;

b)

cout<<pAge;

c)

cout<<*pAge;

d)

cout<<*&pAge;

21.

Which statement about structures in C++ is TRUE?

a)

A structure can hold different data types

b)

A structure cannot contain arrays

c)

Structure members must have the same type

d)

Structures do not support pointers

22.

Choose the CORRECT statement related to functions.

a)

Reference parameters pass by value

b)

Actual arguments provide two-way communication

c)

Arrays can be passed as function arguments

d)

Structures cannot be accessed from functions

23.

Choose the function prototype in the given program.

a)

Y

b)

T

c)

M

d)

R

24.

Choose the function call in the given program.

a)

Y

b)

T

c)

M

d)

R

25.

Select the correct type of function.

a)

with arguments and no return value

b)

with arguments and with return value

c)

without arguments and no return value

d)

without arguments and with return value

26.

Choose the correct function header for 'Sum'.

a)

float Sum(float a, float b);

b)

float Sum(float a, float b)

c)

void Sum(float a, float b);

d)

void Sum(float a, float b)

27.

Determine the output for Figure A29.

a)

178

b)

10078

c)

100+78

d)

100 + 78 = 178

28.

Determine the output for Figure A30.

a)

Total value is: 300, Total value is: 120

b)

Total value is: 100, Total value is: 200

c)

Total value is: 300, Total value is: 120

d)

300, 100

29.

Identify the correct function declaration.

a)

int function(int x);

b)

function(int x);

c)

int function(x);

d)

void function(int x);

30.

What is the purpose of passing parameters by reference?

a)

To pass a copy of the variable

b)

To modify the actual variable in the calling function

c)

To prevent modifications to the variable

d)

To improve execution speed