Professional Documents
Culture Documents
Part One-40 Part Two - 60
Part One-40 Part Two - 60
NOTE:
1. There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions and
PART TWO contains FOUR questions.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will be
supplied at the table when the answer sheet for PART ONE is returned. However,
candidates who complete PART ONE earlier than one hour, can collect the answer book for
PART TWO immediately after handing over the answer sheet for PART ONE.
TOTAL TIME: 3 HOURS TOTAL MARKS: 100
(PART ONE-40; PART TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most appropriate
one and enter in the “tear-off” answer sheet attached to the question paper, following
instructions therein. (1 x 10)
1.1 Assume that variable x resides at memory location 100, y at 200 and ip at 1000.
int x=1; y=2; int *ip;
ip=&x
y=*ip
What will be the value of y after execution of above code?
A) 1
B) 2
C) 100
D) 1000
1.3 Which of the following keyword is used to jump out of a loop without waiting to get back to
the conditional test?
A) break
B) continue
C) while
D) exit
1.5 Which of the following is the correct way of declaring an array of integer pointers?
A) int *arr[10];
B) int arr[10];
C) *int arr[10];
D) int *arr;
1.7 Which of the following is returned by the function ‘strcmp’ if the strings that are compared are
identical?
A) 0
B) 1
C) 2
D) true
1.9 The statement that defines an input file handle called input_file, which is a pointer to type
FILE, is:
A) FILE*input_file;
B) type input _file as FILE;
C) input_file FILE;
D) *FILE input_file;
2.1 Operation between integer and real(float) always yields a real result.
2.2 The while and for loops cannot be nested loops the way if statements can be nested.
2.3 The advantage of ‘switch’ statement over ‘if’ is that it leads to more structured program.
2.4 Strings are arrays of characters terminated by the null character.
2.5 A pointer is a variable that points to another variable.
2.6 The variables commonly used in ’C’ functions are available to all functions in a program.
2.7 fopen() function returns a pointer to the open file.
2.8 Character data types cannot be declared as unsigned.
2.9 The statement which prints out the value of the integer variable sum, is printf(“%s”, sum);
2.10 The char variable is used to store the largest number less than 128.
3. Match words and phrases in column X with the closest related meaning/
word(s)/phrases in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 Several built in functions in 'C' that can be called A. Library
at any time
3.2 A collection of values of the same type B. An Array
3.3 A decision control structure C. The if-else statement
3.4 Logical AND operator D. &&
3.5 Finding length of a string E. strlen()
3.6 Passing address of variables to a function F. Call by reference
3.7 Reading formatted data from the standard input G. scanf()
stream
3.8 Preprocessor statement H. #define
3.9 A data type suitable for grouping data elements I. A Structure
together
3.10 Dynamic memory allocation J. calloc, sizeof, free
K. functions
L. gets()
A. switch-case-default B. while C. 5
D. & E. linked list F. #include<stdio.h>
G. main() H. puts I. sizeof
J. for K. 20 L. null
M. getchar() N. fopen() O.
4.1 The statement within the _______ loop would keep on getting executed till the condition
being tested remains true.
4.2 The control statement, which allows us to make a decision from the number of choice, is
called a(n) _______.
4.4 ‘C’ provides a special operator _______ which gives the size of basic data types in bytes.
4.5 A(n) _______ is comprised of a series of nodes, each node containing a data element and a
pointer to the next node.
4.6 The statement printf(“%20.5s\n”s) means that the first _______ characters are printed of an
arrays.
4.8 The _______ function, accepts the pathname for the file and the access mode.
4.10 The _______ acts as a check to make sure you are using the input and output commands
properly.
5.
a) What does the scope of variable refer in ‘C’ language?
b) Write a program to sort a given list of number using Bubble sort algorithm.
(5+10)
6.
a) What is a Pointer? How can you use pointers with Array if you want to copy elements of
array a into array b.
b) We have a Single linked list as following:
Head 5 9 1
7.
a) Create a program that prints a Fahrenheit-to-Celsius conversion with a for loop or a while
loop; where Celsius=((f-32) * 5/9); and Fahrenheit is denoted by f.
b) While purchasing certain items a discount of 10% is offered if the quantity purchased is more
than 2000. Write a program to calculate the total expenses, if quantity and price per item are
entered through keyboard.
(7+8)
8.
a) Write a program to determine whether a number is prime or not.
b) Write a recursive function to obtain the first 25 numbers of a Fibonacci sequence. In
Fibonacci sequence the sum of two successive terms gives the third term. The following are
few terms of Fibonacci sequence:
1 1 2 3 5 8 13 21 ....
(7+8)
9. Create a program that reads in a string containing a first name followed by a blank followed
by a last name. Write functions to remove any leading or trailing blanks. Write another
function that return the last name.
(15)
NOTE:
1. There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions
and PART TWO contains FOUR questions.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO
will be supplied at the table when the answer sheet for PART ONE is returned.
However, candidates who complete PART ONE earlier than one hour, can collect
the answer book for PART TWO immediately after handing over the answer sheet
for PART ONE.
TOTAL TIME: 3 HOURS TOTAL
MARKS: 100
(PART ONE-40; PART
TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the
question paper, following instructions therein.
(1 x 10)
A) p1 +2
B) p2 - 2
C) p2 - p1
D) p2 +p1
1.2 The second expression (j – k), in the following expression will be evaluated
(i + 5) || (j - k)
1.4 Which of the following statement is not true for register variable?
A) Hello Hello
B) Hello world
C) world world
D) the program will not compile
A) B
B) b
C) BC
1.8 How many values at the most can be returned to the calling function through a single
return statement?
A) 0
B) 1
C) 2
D) any number of values
A) #include
B) #ifdef
C) #define
D) #undef
2. Each statement below is either TRUE or FALSE. Choose the most appropriate
one and ENTER in the “tear-off” sheet attached to the question paper,
following instructions therein.
(1 x 10)
2.1 The size of a pointer to an integer is same as the size of a pointer to a struct variable
having four integer data members.
2.2 The contents of a file opened in “r+” cannot be changed.
2.3 The mod operator (%) can operate on float data.
2.4 Every if statement can be converted into an equivalent switch statement.
2.5 The only property of a recursive function is that it calls itself again and again.
2.6 All members of a union are allocated contiguous memory locations.
2.7 The main() function can call itself recursively.
2.8 No two constants in an enum can have same value.
2.9 (i + j)++ is illegal.
3. Match words and phrases in column X with the closest related meaning/
word(s)/phrases in column Y. Enter your selection in the “tear-off” answer
sheet attached to the question paper, following instructions therein.
(1 x 10)
X Y
3.1 A homogeneous data structure A. declaration
3.2 A non-linear data structure B. register
3.3 a return in main( ) C. int *p[10]
3.4 Logical AND D. gets
3.5 Left to right precedence operator E. static variable
3.6 Space allocation F. &
3.7 Retains value across the function calls G. ?:
3.8 Pointer to a function H. structure
3.9 Returns a pointer to an integer I. array
3.10 To read a line from standard input J. getline
K. terminate program
L. int (*p)[10];
M. linked llist
N. int *p(void);
O. auto
P. definition
Q. int (*p)(void);
R. &&
4.6 Within a multifile program, a(n) __________ variable can be defined in one file and
accessed in another.
4.9 Let str be a string of 5 characters, then printf(“%3s”, str); will display __________
characters.
4.10 The subscript positions(s) __________ need not be included in the formal argument
declaration of an array.
PART TWO
(Answer any FOUR questions)
5. Write a C program to copy only those lines from one file to another that have more
than 80 characters. Also print the line numbers in the new file. The line numbers
must be with respect to the original file. Assume there are at the most 100 characters
in a line.
(15)
6.
a) Write a C function, ‘str_search’, that takes two strings, as arguments and returns a
pointer to the first occurrence of 1st string in 2nd string, or NULL if it is not present.
b) Write a recursive C function, power (, b) to compute ab. Assume a and b are non-
negative integers.
(9+6)
7.
a) Write a C function to remove duplicates from an ordered array. For example, if input
is – 1,1,1,3,4,4,5,8,8,10 then output should be 1,3,4,5,8,10.
b) Write a recursive C function to print the reverse of a string.
(9+6)
8. Write a C program to generate a triangle with fibonacci numbers (series given below)
as elements of every row. For example, for m = 5, the output should be
1
1 1
9.
a) Define a structure of anode of a linked list having an integer data member x.
b) Use the above structure in (a) and write the functions for the following parts;
i) a function which takes a pointer to the head of linked list, which is in ascending order
and an integer, x to be inserted in the linked list, as arguments. The node must be
inserted in such a way that the linked list remains in ascending order after insertion.
ii) a function which takes a pointer to the head of a linked list and an integer, x to be
removed from the linked list, as arguments. If x is not found in the linked list, then it
should display an appropriate message.
(3+ [6 + 6])