NEW
Font size
WorksheetsExtra Test_DFC2073 Programming Fundamentals
Total questions: 50
Worksheet time: 2hrs 40mins
Identify THREE (3) types of error in programming.
Syntax errors, single time errors and logical errors
Syntax errors, run rime errors and logical errors
Grammatical errors, single time errors and logical errors
Grammatical errors, run time errors and logical errors
Select the type of error that refer to the statement below:
'Error in the syntax of a sequence of characters that is intended to be written in a particular programming language.'
Logic error
Syntax error
Run–time error
Break–time error
Observe the above statement to identify the type of error occurred.
Logic error
Syntax error
Run–time error
Operator error
Identify the symbol which must end the C++ code statement.
Comma ( , )
Semicolon ( ; )
Colon ( : )
Quotation Marks (“ ”)
Which one of the following answers is used as the header file for mathematical function of sqrt( )?
stdlib.h
string.h
conio.h
math.h
“A location in the memory that store data that never changes during the execution of the program.”
Select the CORRECT answer for the statement.
Variables
Identifiers
Constant
Keywords
Identify the operator to compares the two variables.
=
%
>=
++
Below is a correct rule in naming a variable in C++, EXCEPT:
Must begin with number
No space in between
Variable name must be unique
Cannot have symbols or special characters
Classify type of errors in above code.
Logical Error
Syntax Error
Run Time Error
Compiler Error
Recognize a syntax error in the above program.
Missing int for the variable b and sum in line 4
Wrong operator in line 5
Missing << in cout line 6
Have to use symbol { at the end program
Select the INCORRECT identifier based on the following answers below.
n6umber;
6number;
number6;
number_6;
Choose the CORRECT declaration of an identifier named as ‘Sum’ with double type.
double Sum;
double *Sum;
DOUBLE Sum:
double sum = 0;
State the main different between global n local variable.
Local variable can use to all the programs.
Global variable can use to all the programs.
Global and local variable can use to specific program.
Global and local variable can use to all the programs.
Define debugging process.
Finding and correcting error in the program code
Creating program code
Identifying the task to be computerized
Creating the algorithm
Interpret the following operation by considering the precedence of arithmetic operators.
(9 – (3 + 2 ) ) * 3 = ?
24
23
6
12
Choose the CORRECT value of ‘Y’ in the above statements.
14
13
16
18
Predict the output for the above logical expression.
16 1 0 0
16 1 0 1
16 1 1 0
16 1 1 1
Based on the above statement, determine the CORRECT output after execution.
a = 5
b = 4
a = 5
b = 3
a = 6
b = 4
a = 6
b = 3
Interpret the above code to find the CORRECT output.
5 6
6 5
6 7
6 8
Choose the CORRECT output when the above segment code is executed.
3.0
4
3
3.8
Identify which is NOT the type of looping control structures.
for
while
if…else
do…while
Explain program control structure.
i. An if statement can be followed by an optional else if and else statement, which are very useful to test various conditions.
ii. The else if statement is used to check for a sequence of conditions, when one condition is false, it checks for next condition and so on
iii. When all the conditions are false, the else block is executed
iv. Once the condition is true, all the other else if statements are executed.
i, ii and iii
i, ii and iv
i, iii and iv
ii, iii and iv
Discover the following for loop statements that will count from 1 to 10.
for (var a = 1; a <= 10; a++)
for (var a = 1; a < 10; a++)
for (var a == 1; a <= 1; a++)
for (var a = 1; a ==10; a++)
Predict the outputs for the above programs when ‘a = 4’.
odd number
even number
odd numbereven number
null
Select the segment code which DOES NOT produce the given output.
Predict the CORRECT output for the above code.
I have 9 Bhat
I have 9 Rupiah
I have 9 Dollars
I have 9 Ringgit Malaysia
Discover the part of code above to find the CORRECT output of ‘x’.
1 3 5 7
7 5 3 1
1 2 3 4 5 6 7
7 6 5 4 3 2 1
Based on the program, predict the output when inputChar = ‘a’.
Null
Politeknik
Politeknik Seberang
Politeknik Seberang Perai
Complete the part of do..while code above with the CORRECT condition for ‘W’ in order to produce output of:
3, 5, 7, 9.
a<=10
a>10
a<9
a<=9
Choose the suitable statement for ‘X’ to produces the output of:
1 2 3.
while (i<3)
while (i<4)
while (i<=4)
while (i<=2)
Interpret the above statement with CORRECT definition of one dimensional array declaration.
size_of_array specifies how many elements in the array and the size is not fixed.
Array_name is the name of the declared array and must comply with the rules for naming the identifier.
Data_type of array indicates what data type of identifier that can have different data type with different values.
The position of each array element is known as array index or subscript is declared using [ ] operator and initialize with index 1.
Show the CORRECT declaration of one dimensional array.
int array;
array{5};
int array[5];
array array[5];
Identify which of the following statement is FALSE of the declaration above:
Integer array data type
[10] refer to size of an array
Contains ten elements
The last index is 10
Discover how many elements in the above array declaration.
4
5
0
6
Choose the CORRECT answer that relate to the following statement:
“Assign value 10 to Number array with index 15.”
Number[10] = 15;
Number[15] = 10;
Number[15][10];
Number[10][15];
Apply C++ syntax to create the two dimensional array named nums with 20 rows and 2 columns that holds 40 pointing numbers.
float nums [2][20];
float nums [20][2];
int nums [20][2];
int nums [2][20];
Predict the output for the code segment above:
5
7, 9
9
1, 3
Determine the suitable statement for ‘Z’ that produces an output 9.
cout<< covid[1][1] + covid[3][1];
cout<< covid[0][0] + covid[2][1];
cout<< covid[0][0] + covid[3][1];
cout<< covid[1][1] + covid[2][1];
Analyze the output for the above part of program coding.
HO
HOHOME
OHOME
MHOME
Based on the above part of code, identify ‘hand_phone’ structure object.
Hand_phone
char, int, float
samsung, iphone
model, weight, price
Based on the above part of code, identify ‘Car’ structure members.
Audi, BMW
Car
char, int, float
model, type, price
Analyze the above program below to get the CORRECT statement for ‘P’.
planet star1
struct planet star1
planet star1 struct
struct planet name distance
Select the CORRECT statement that store the memory address of a pointer ‘B’.
B
*B
&B
address(B)
Base on the above segment code, choose the CORRECT statement to display the value of ‘value1’.
cout<<&value1;
cout<<*value2;
cout<<value2;
cout<<*value1;
Determine the CORRECT way to initialize a pointer to receive value.
int *a;
int add=200;
a=&add;
int &a;
int add=200;
a=*add;
int *a;
int add=200;
*a=add;
int &a;
int add=200;
add=*a;
Analyze the segment code above and detect the suitable line code which hold the value of ‘num2’.
*number1=number2;
number2-*number1;
number2=*pnumber;
&number1=*pnumber;
If the user want to create a function to calculate discount that will receive parameter price of float type and will return float value, discover the CORRECT statement can be used to create the function.
void price(float cal_discount)
float price(float cal_discount)
float cal_discount (float price)
void cal_discount (float price)
Predict the output for the above program code.
9
3
sqrt(9);
sqrt(y);
Determine the type of component ‘T’ in the above program code.
Function body
Function definition
Function call
Function prototype
Analyze the above program below to get the CORRECT output for ‘z’.
nul
syntax error
5
6
