NEW
Font size
WorksheetsC++ Programming Quiz sesi (ii) 2023/2024
Total questions: 30
Worksheet time: 15mins
Identify THREE (3) types of error in programming.
Grammatical error, single time error, logical error
Syntax error, run-time error, logical error
Syntax error, mathematical error, single error
Grammatical error, calculation error, logic error
Identify the CORRECT answer to represent the statement shown in Figure A2.
Identifiers
Variable
Constant Variable
Data Types
Identify the acceptable ways to define variables.
int a; b;
int a, int b;
int a; double b;
int a, double b;
Identify the suitable symbol that is used for initialization in Programming.
;
_
<<
=
Choose the CORRECT C++ syntax to declare a variable named “Address” of string type.
char Address;
char Address (20);
string address;
string address (20);
Choose the suitable answer for a variable based on the given statement.
Local variable
Global Variable
Function Variable
Class Variable
Trace the output of the given C++ program in Figure A7.
4, 3, 3, 1
4, 3, 3, 0
4,
3,
3,
0
4,
3,
3,
1
Which of the following is used for input in C++?
cout
cin
printf
scanf
Identify the answer that is NOT related to a looping control structure.
for
while
do
do..while
Identify the number of repetitions in Figure A10.
18
19
20
21
Choose the correct C++ statement to print a message 12 times.
for (int count = 1; count <= 11; count++)
for (int count = 1; count < 11; count++)
for (int count = 2; count < 11; count++)
for (int count = 0; count <= 11; count++)
Given the following code, identify the value of 'y' after execution.
0
1
2
3
Determine the output based on the given C++ program.
3 5 7 9 11
1 3 5 7 9
3 6 8 9 10
1 3 6 9 11
What happens if a break statement is omitted in a switch case?
The next case executes
The program crashes
Only the first case executes
An error occurs
Select the CORRECT answer to explain arrays.
It saves storage space storing under one name
Able to store things related to different topics
Can store integers and strings together
Group of memory locations with the same name and type
Identify elements in the following array in Figure A16 below.
14
13
15
12
Choose the correct structure declaration from Figure A17.
struct CDCollection
{float Price;}
RockNRoll;
struct CDCollection
{float Price;}
RockNRoll;
struct RockNRoll
{float Price;}
CDCollection;
struct Price
{float RockNRoll;}
CDCollection;
Determine the output for Figure A18.
6 2 3 4 1 5
5 1 4 3 2 6
6 2 3 4 1 5
6 2 3 4 1 5
Determine the output for Figure A19.
23 18
33 28
33 5
23 5
Choose the statement to display the value of 'Age'.
cout<<&pAge;
cout<<pAge;
cout<<*pAge;
cout<<*&pAge;
Which statement about structures in C++ is TRUE?
A structure can hold different data types
A structure cannot contain arrays
Structure members must have the same type
Structures do not support pointers
Choose the CORRECT statement related to functions.
Reference parameters pass by value
Actual arguments provide two-way communication
Arrays can be passed as function arguments
Structures cannot be accessed from functions
Choose the function prototype in the given program.
Y
T
M
R
Choose the function call in the given program.
Y
T
M
R
Select the correct type of function.
with arguments and no return value
with arguments and with return value
without arguments and no return value
without arguments and with return value
Choose the correct function header for 'Sum'.
float Sum(float a, float b);
float Sum(float a, float b)
void Sum(float a, float b);
void Sum(float a, float b)
Determine the output for Figure A29.
178
10078
100+78
100 + 78 = 178
Determine the output for Figure A30.
Total value is: 300, Total value is: 120
Total value is: 100, Total value is: 200
Total value is: 300, Total value is: 120
300, 100
Identify the correct function declaration.
int function(int x);
function(int x);
int function(x);
void function(int x);
What is the purpose of passing parameters by reference?
To pass a copy of the variable
To modify the actual variable in the calling function
To prevent modifications to the variable
To improve execution speed
