wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Extra Test_DFC2073 Programming Fundamentals

Total questions: 50

Worksheet time: 2hrs 40mins

Name
Class
Date
1.

Identify THREE (3) types of error in programming.

a)

Syntax errors, single time errors and logical errors

b)

Syntax errors, run rime errors and logical errors

c)

Grammatical errors, single time errors and logical errors

d)

Grammatical errors, run time errors and logical errors

2.

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.'

a)

Logic error

b)

Syntax error

c)

Run–time error

d)

Break–time error

3.

Observe the above statement to identify the type of error occurred.

a)

Logic error

b)

Syntax error

c)

Run–time error

d)

Operator error

4.

Identify the symbol which must end the C++ code statement.

a)

Comma ( , )

b)

Semicolon ( ; )

c)

Colon ( : )

d)

Quotation Marks (“ ”)

5.

Which one of the following answers is used as the header file for mathematical function of sqrt( )?

a)

stdlib.h

b)

string.h

c)

conio.h

d)

math.h

6.

“A location in the memory that store data that never changes during the execution of the program.”


Select the CORRECT answer for the statement.

a)

Variables

b)

Identifiers

c)

Constant

d)

Keywords

7.

Identify the operator to compares the two variables.

a)

=

b)

%

c)

>=

d)

++

8.

Below is a correct rule in naming a variable in C++, EXCEPT:

a)

Must begin with number

b)

No space in between

c)

Variable name must be unique

d)

Cannot have symbols or special characters

9.

Classify type of errors in above code.

a)

Logical Error

b)

Syntax Error

c)

Run Time Error

d)

Compiler Error

10.

Recognize a syntax error in the above program.

a)

Missing int for the variable b and sum in line 4

b)

Wrong operator in line 5

c)

Missing << in cout line 6

d)

Have to use symbol { at the end program

11.

Select the INCORRECT identifier based on the following answers below.

a)

n6umber;

b)

6number;

c)

number6;

d)

number_6;

12.

Choose the CORRECT declaration of an identifier named as ‘Sum’ with double type.

a)

double Sum;

b)

double *Sum;

c)

DOUBLE Sum:

d)

double sum = 0;

13.

State the main different between global n local variable.

a)

Local variable can use to all the programs.

b)

Global variable can use to all the programs.

c)

Global and local variable can use to specific program.

d)

Global and local variable can use to all the programs.

14.

Define debugging process.

a)

Finding and correcting error in the program code

b)

Creating program code

c)

Identifying the task to be computerized

d)

Creating the algorithm

15.

Interpret the following operation by considering the precedence of arithmetic operators.


(9 – (3 + 2 ) ) * 3 = ?

a)

24

b)

23

c)

6

d)

12

16.

Choose the CORRECT value of ‘Y’ in the above statements.

a)

14

b)

13

c)

16

d)

18

17.

Predict the output for the above logical expression.

a)

16 1 0 0

b)

16 1 0 1

c)

16 1 1 0

d)

16 1 1 1

18.

Based on the above statement, determine the CORRECT output after execution.

a)

a = 5

b = 4

b)

a = 5

b = 3

c)

a = 6

b = 4

d)

a = 6

b = 3

19.

Interpret the above code to find the CORRECT output.

a)

5 6

b)

6 5

c)

6 7

d)

6 8

20.

Choose the CORRECT output when the above segment code is executed.

a)

3.0

b)

4

c)

3

d)

3.8

21.

Identify which is NOT the type of looping control structures.

a)

for

b)

while

c)

if…else

d)

do…while

22.

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.

a)

i, ii and iii

b)

i, ii and iv

c)

i, iii and iv

d)

ii, iii and iv

23.

Discover the following for loop statements that will count from 1 to 10.

a)

for (var a = 1; a <= 10; a++)

b)

for (var a = 1; a < 10; a++)

c)

for (var a == 1; a <= 1; a++)

d)

for (var a = 1; a ==10; a++)

24.

Predict the outputs for the above programs when ‘a = 4’.

a)

odd number

b)

even number

c)

odd numbereven number

d)

null

25.

Select the segment code which DOES NOT produce the given output.

a)
b)
c)
d)
26.

Predict the CORRECT output for the above code.

a)

I have 9 Bhat

b)

I have 9 Rupiah

c)

I have 9 Dollars

d)

I have 9 Ringgit Malaysia

27.

Discover the part of code above to find the CORRECT output of ‘x’.

a)

1 3 5 7

b)

7 5 3 1

c)

1 2 3 4 5 6 7

d)

7 6 5 4 3 2 1

28.

Based on the program, predict the output when inputChar = ‘a’.

a)

Null

b)

Politeknik

c)

Politeknik Seberang

d)

Politeknik Seberang Perai

29.

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)

a<=10

b)

a>10

c)

a<9

d)

a<=9

30.

Choose the suitable statement for ‘X’ to produces the output of:

1 2 3.

a)

while (i<3)

b)

while (i<4)

c)

while (i<=4)

d)

while (i<=2)

31.

Interpret the above statement with CORRECT definition of one dimensional array declaration.

a)

size_of_array specifies how many elements in the array and the size is not fixed.

b)

Array_name is the name of the declared array and must comply with the rules for naming the identifier.

c)

Data_type of array indicates what data type of identifier that can have different data type with different values.

d)

The position of each array element is known as array index or subscript is declared using [ ] operator and initialize with index 1.

32.

Show the CORRECT declaration of one dimensional array.

a)

int array;

b)

array{5};

c)

int array[5];

d)

array array[5];

33.

Identify which of the following statement is FALSE of the declaration above:

a)

Integer array data type

b)

[10] refer to size of an array

c)

Contains ten elements

d)

The last index is 10

34.

Discover how many elements in the above array declaration.

a)

4

b)

5

c)

0

d)

6

35.

Choose the CORRECT answer that relate to the following statement:


“Assign value 10 to Number array with index 15.”

a)

Number[10] = 15;

b)

Number[15] = 10;

c)

Number[15][10];

d)

Number[10][15];

36.

Apply C++ syntax to create the two dimensional array named nums with 20 rows and 2 columns that holds 40 pointing numbers.

a)

float nums [2][20];

b)

float nums [20][2];

c)

int nums [20][2];

d)

int nums [2][20];

37.

Predict the output for the code segment above:

a)

5

b)

7, 9

c)

9

d)

1, 3

38.

Determine the suitable statement for ‘Z’ that produces an output 9.

a)

cout<< covid[1][1] + covid[3][1];

b)

cout<< covid[0][0] + covid[2][1];

c)

cout<< covid[0][0] + covid[3][1];

d)

cout<< covid[1][1] + covid[2][1];

39.

Analyze the output for the above part of program coding.

a)

HO

b)

HOHOME

c)

OHOME

d)

MHOME

40.

Based on the above part of code, identify ‘hand_phone’ structure object.

a)

Hand_phone

b)

char, int, float

c)

samsung, iphone

d)

model, weight, price

41.

Based on the above part of code, identify ‘Car’ structure members.

a)

Audi, BMW

b)

Car

c)

char, int, float

d)

model, type, price

42.

Analyze the above program below to get the CORRECT statement for ‘P’.

a)

planet star1

b)

struct planet star1

c)

planet star1 struct

d)

struct planet name distance

43.

Select the CORRECT statement that store the memory address of a pointer ‘B’.

a)

B

b)

*B

c)

&B

d)

address(B)

44.

Base on the above segment code, choose the CORRECT statement to display the value of ‘value1’.

a)

cout<<&value1;

b)

cout<<*value2;

c)

cout<<value2;

d)

cout<<*value1;

45.

Determine the CORRECT way to initialize a pointer to receive value.

a)

int *a;

int add=200;

a=&add;

b)

int &a;

int add=200;

a=*add;

c)

int *a;

int add=200;

*a=add;

d)

int &a;

int add=200;

add=*a;

46.

Analyze the segment code above and detect the suitable line code which hold the value of ‘num2’.

a)

*number1=number2;

b)

number2-*number1;

c)

number2=*pnumber;

d)

&number1=*pnumber;

47.

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.

a)

void price(float cal_discount)

b)

float price(float cal_discount)

c)

float cal_discount (float price)

d)

void cal_discount (float price)

48.

Predict the output for the above program code.

a)

9

b)

3

c)

sqrt(9);

d)

sqrt(y);

49.

Determine the type of component ‘T’ in the above program code.

a)

Function body

b)

Function definition

c)

Function call

d)

Function prototype

50.

Analyze the above program below to get the CORRECT output for ‘z’.

a)

nul

b)

syntax error

c)

5

d)

6