0% found this document useful (0 votes)
46 views8 pages

Final Exam

The document is a final exam paper consisting of multiple-choice questions and programming tasks related to C programming concepts. It covers topics such as arrays, pointers, functions, control structures, and file handling. Additionally, it includes practical programming exercises requiring students to fill in code and answer questions about C syntax and operations.

Uploaded by

sushan.khatrij24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views8 pages

Final Exam

The document is a final exam paper consisting of multiple-choice questions and programming tasks related to C programming concepts. It covers topics such as arrays, pointers, functions, control structures, and file handling. Additionally, it includes practical programming exercises requiring students to fill in code and answer questions about C syntax and operations.

Uploaded by

sushan.khatrij24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

CT018-3-1-ICP Final Exam Page 1 of 8

SECTION A
Multiple Choice Questions
Answer ALL Questions
This section carries 25 marks

1. ____ is a group of related values with the same data type that is stored using a single
group name.
A. Array
B. Struct
C. File
D. Variable

2. Following statements are TRUE regarding the array except


A. Each item in an array is called an element of the array.
B. The element’s position is known as subscript or index.
C. The first element has a subscript of 1.
D. Elements can be initialized within the declaration statement using curly braces, “{}”.

3. What is the size of the following array?


float length[] = {7, 4, 0, 1};
A. 4
B. 7
C. 1
D. unknown

4. A pointer contains a(n) ____ of another variable that contains a value.


A. asterisk
B. address
C. operator
D. value

5. An array _____ can be treated as a pointer and used in pointer arithmetic expression.
A. element
B. index
C. name
D. size

6. The unary operator that returns the address of its operand.


A. %
B. &
C. *
D. +

7. C program file names should end with the ___________ extension.


A. .c
B. .o
C. .cpp
D. .a

Level 1 Asia Pacific University of Technology & Innovation 2024/4


CT018-3-1-ICP Final Exam Page 2 of 8

8. The compiled code is called the ______.


A. c code
B. object code
C. program code
D. source code

9. Re-arrange the following process into proper sequence as per the compilation pipeline.
I. Source Code
II. Assembler
III. Compiler
IV. Linker
V. Machine Executable Code
VI. Preprocessor

A. I, II, III, IV, V, VI


B. I, VI, III, II, IV, V
C. I, III, II, IV, VI, V
D. I, III, II, VI, IV, V

10. Which of the following statements is NOT TRUE regarding the function concept?
A. Arguments can be passed to a function using call-by-value or call-by-reference.
B. A function with a return-data-type “void”, will not return the control back to the
caller.
C. Function prototypes enable the compiler to verify that functions are called correctly.
D. The arguments passed to a function should match in number, type and order with the
parameters in the function definition.

11. C provides four storage classes to determine the storage duration, scope and linkage.
These four storage classes are
I. auto III. extern V. register
II. class IV. storage VI. static

A. I,II,III,IV
B. I,III,V,VI
C. I,IV,V,VI
D. I,III,V,VI,

12. A pair of braces ‘{}’ and the portion of the program between the braces is called a
______.
A. Block
B. Program
C. Statements
D. code

13. Every statement must end with a ______.


A. Function
B. Newline
C. keywords
D. Semicolon

Level 1 Asia Pacific University of Technology & Innovation 2024/4


CT018-3-1-ICP Final Exam Page 3 of 8

14. “while”, “do...while” and “for” are the example of _____ control structure.
A. Sequence
B. selection
C. repetition
D. program

15. Counter-controlled repetition is often called definite repetition because _____


A. the number of repetitions is known before the loop begins executing.
B. the number of repetitions is not known before the loop begins executing.
C. a variable known as counter is used
D. the variable counter will specific the number of times a set of statements should
execute.

16. The compiler normally issues an error message to help you locate and fix the incorrect
statement. It also known as compile errors, or compile-time errors.
A. Logic errors
B. Runtime errors
C. Syntax errors
D. All of the above

17. Following identifiers are valid except


A. _value1
B. value1
C. value_1
D. value$1

18. The _____ statement is called a multiple-selection statement because it selects among
many different actions.
A. switch
B. If
C. If…else
D. else…if

19. Following statements are TRUE about the C struct except


A. Structure members share the same storage space.
B. They may contain variables of many different data types.
C. Each structure definition must end with a semicolon.
D. Program access a structure member via the structure variable name.

20. The file open mode____ indicates that the file is to be opened for writing. If the file does
not exist, fopen creates the file. If the exists, the contents are discarded without warning.
A. a
B. c
C. r
D. w

21. A linked list is a linear collection of self-referential structures, called nodes. Which of the
following is self-referential structure?

Level 1 Asia Pacific University of Technology & Innovation 2024/4


CT018-3-1-ICP Final Exam Page 4 of 8

A.
struct Node {
char data;
struct Node *nextPtr;
};

B.
struct Node {
char data;
};

C.
Node {
Node *nextPtr;
};

D.
Node {
char data;
};

22. How many times the block of code will run when x is assigned with 1 in the following
snippet of code?

while(x<10){
sum += x;
x++;
}

A. 1
B. 10
C. 9
D. Unknown

23. Given the following snippet of code, what the program trying to achieve?
for ( i = 1; i < SIZE; i++ ) {
for ( j= 0; j < SIZE – 1; j++ ) {
if (a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]= temp;
}
}
}
A. Sort the values in the array ‘a’ in ascending order
B. Sort the values in the array ‘a’ in descending order
C. Move the values in the array ‘a’ into the next index sequence.
D. Iterate through each value in the array ‘a’.

24. The _____ searching method works well for small or unsorted arrays.

Level 1 Asia Pacific University of Technology & Innovation 2024/4


CT018-3-1-ICP Final Exam Page 5 of 8

A. linear
B. binary
C. bubble
D. file
25. What is the format conversion specifier used to read character with scanf function.
A. %d
B. %s
C. %c
D. %f

Level 1 Asia Pacific University of Technology & Innovation 2024/4


CT018-3-1-ICP Final Exam Page 6 of 8

SECTION B
Answer ALL questions
This section carries 25 marks

Question B1

Following program will receive an input (height) from the operator and print the bottom left
triangle pattern (*) using C function concept based on the height. You are required to fill in
the blanks in the program.

__a___ <stdio.h>
void PrintBottomLeftTrianglePattern(_b___); //function
prototype
int main() {
int height;
do{
printf("Enter height: ");
scanf("__c__",__d__); //read user input, height
if(__e___) // check the height, value should be 1 or
more
printf("Invalid value, please enter height again!\
n");
}while(height<=0);
printf("\n----Bottom Left Triangle Pattern----\n");
____f_____(height); //function call
return 0;
}
//function definition
void PrintBottomLeftTrianglePattern(int height){
int __g___,col;
for (row =0; row<height; row++) {
for(col=0;__h__; col++)
printf("__i_"); //print pattern "*"
printf("_j__"); //print newline
}
}

Sample input-output

Level 1 Asia Pacific University of Technology & Innovation 2024/4


CT018-3-1-ICP Final Exam Page 7 of 8

[10 marks]

Level 1 Asia Pacific University of Technology & Innovation 2024/4


CT018-3-1-ICP Final Exam Page 8 of 8

Question B2

a) List FIVE(5) keywords / reserved words in C programming language.


[5 marks]

b) Given a =1,b=2,c=3 and d=4, what will be the output of the following expression?
i. a+b*c
ii. c*d/b
iii. a%b
iv. ++c
v. c==d
vi. b?a:b
vii. -d
[7 marks]

c) Write a single C statement to accomplish each of the following.


i. Initialize variable sum to 0.
ii. Print the integer value of variable called age.
iii. Assign the address of variable number1 to pointer variable fPtr.

[3 marks]

Level 1 Asia Pacific University of Technology & Innovation 2024/4

You might also like