M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH ‘C’ LANGUAGE
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and
PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to the
question paper, as per the instructions contained therein. PART ONE is NOT to be
answered in the answer book.
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)
1. Each question below gives a multiple choice of answers. Choose the most
(Answer all the questions)
appropriate one and enter in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1x10)
1.1 ‘C’ Programming Language was developed and written by
A) Martin Richards
B) Dennis Ritchie
C) Ken Thompson
D) Herman Hellorith
1.2 Which of the following is false in ‘C’ Programming Language
A) Keywords can be used as variable names
B) Variable names can contain digits
C) Variable names do not contain blank spaces
D) Capital letters can be used in variable names.
1.3 What will be the output of the following ‘C’ program
printf(“a and b are equal”);
printf(“a and b are different”);
A) a and b are equal
B) a and b are different
D) None of the above
1.4 What will be the output of the following ‘C’ program?
printf(“I will certainly pass”);
printf(“I am not so sure about the result”);
A) I will certainly pass
B) I am not so sure about the result
D) None of the above
1.5 What will be the output of the following program?
D) Unpredictable Value
1.6 A ‘C’ expression contains relational, assignment and arithmetic operators. There are no
parentheses used. They will be evaluated in which of the following order
A) Assignment Relational Arithmetic
B) Arithmetic Relational Assignment
C) Relational Arithmetic Assignment
D) Assignment Arithmetic Relational
1.7 Prototype of function named ‘fun’ is: int fun(int a, float b) Which of the following is
true about function ‘fun’:
A) It takes two inputs, one integer type and the other float type but returns nothing
B) It takes two inputs, one integer type and the other float type but returns 0
C) It takes two inputs, one integer type and the other float type but returns an integer
D) It takes two inputs, one integer type and the other integer type but returns float
1.8 What will happen if an element is assigned a value to an element of an array whose
subscript exceeds the size of the array
A) It will not be allowed, but no error message will be generated
B) Compiler will generate an error message suggesting the same
C) The element will be assigned NULL VALUE.
D) Some other data may be overwritten
1.9 In the following ‘C’ code
FILE *f = fopen( fileName, "r");
puts(“End of file reached”);
Which one of the following can replace the ???? in the code above to determine if the end of
a file has been reached?
A) f == EOF
B) feof( f )
C) eof( f )
D) f == NULL
1.10 With every use of a memory allocation function, what function should be used to release
allocated memory which is no longer needed?
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. (1x10)
2.1 A structure can contain pointer to itself.
2.2 Size of all elements in a union should be same.
2.3 Size of a pointer is equal to the data type it points to.
2.4 In ‘C’, the compiler does not check if the subscript used for an array exceeds size of the
2.5 A ‘for’ loop in ‘C’ has three statements, namely, assignment, test and increment statements.
2.6 cout and cin can be used for output and input respectively in ‘C’ language.
2.7 The default initial value of a static int variable is zero.
2.8 Binary search can be easily performed on a linked list.
2.9 A function name can be passed as an argument to another function.
2.10 A ‘C’ function can contain many return statements.
3. Match words and phrases in column X with the closest related meaning/word(s)/phrase(s) in column Y. Enter your selection in the “tear-off” answer sheet attached to the question paper, following instructions therein. (1x10)
X Y3.1 Do-while loop is A. Directives
3.2 This loop control structure takes B. You cannot find its address
you to the beginning of the loop
3.3 This is a mandatory function in C. To clear the specified buffer
every ‘C’ program. Execution starts
from this function
3.4 Value of static storage variable D. continue
3.5 Preprocessor commands are also E. The same data types placed in
known as contiguous memory locations
3.6 An array is a collection of F. Persists between different function
3.7 The condition that a linked list is empty G. Case control structure
3.8 If ‘x’ is a variable of storage class register H. Executed at least once
3.9 If you have to use many if-else conditions, I. Will be there if start== is true.
they can be usually implemented by
3.10 The purpose of library function fflush() is J. main().
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list below. Enter your choice in the “tear-off” answer sheet attached to the question paper, following instructions therein. (1x10)
D. stdio.h E. CPU Registers F. &&
G. fclose() H. 65 I. An Error
J. Array of characters K. \a L. &
4.1 Logical AND operator is denoted by ________.
4.2 Size of char data type is ________.
4.3 The variables of storage class register are stored in ________.
4.4 If you try to multiply or add two pointers, it will result in ________.
4.5 In ‘C’, strings are stored in the form of ________.
4.6 Escape sequence for backspace is ________.
4.7 Function used to close a file is _________.
4.8 The header file which must be included, if you want to use malloc() or calloc() is
4.9 The macro FILE is defined in header file ________.
4.10 The ASCII value, in decimal, of character ‘A’ is ________.
(Answer any FOUR questions)
a) Explain the concept of structured programming in detail.
b) List out the rules to declare a valid variable in ‘C’ program. Evaluate the following expression and show the hierarchy of operations:
( 2 + 4 ) / 3 + 2%3 * 2 – 5
c) Define a structure Time having integer data members hour, minute, second. Write a
program to enter two variables of the type Time and then add these two variables and store
the result into third variable. Also validate the second and minute of the result and print it.
6. A, B and C are three 3x3 matrices containing real elements.
a) Write a ‘C’ function to input from user appropriate values into matrices A and B. Use
suitable loops. Make use of pointers if necessary.
b) Write a ‘C’ function to calculate matrix C such that C=A+B Use suitable loops. Make use of pointers if necessary
c) Write a ‘C’ program to call the above two functions and print Matrix C suitably. Write suitable
prototype etc. Use suitable loops. Make use of pointers if necessary
a) Write and explain the action of WHILE statement. Develop a program in ‘C’ language to
compute the average of every third integer number lying between 1 and 100. Include
b) Develop a function to calculate sum of n even integers starting from a given even integer.
c) Identify all the compound statements which appear in the following program segment:
if (i < 0)
sum += i;
} while (i != 0);
a) Write a ‘C’ program to find the minimum of the 8 floating point numbers and its place in the
b) Write an interactive ‘C’ program to evaluate the series: 1 – 1/2 + 1/3 – 1/4 …±1/n, where n is
entered from keyboard.
c) Write a ‘C’ program to calculate the electricity bill using if..elseif, as per the following
* Given the number of units consumed, unit charges are as follows:
i) For first 50 units Rs. 0.50/unit
ii) For next 100 units Rs. 0.75/unit
iii) For next 100 units Rs. 1.20/unit
iv) For unit above 250 Rs. 1.50/unit
* Add fuel surcharge 20% and Govt. Tax 10% on bill to calculate the total bill.
a) Write a suitable ‘C’ program to print the following structure.
the number of rows should be input from the user.
b) Write a program to input a 3x3 matrix and to print its transpose.
c) Consider outline of ‘C’ program given below:
#Include suitable header files
suitable prototype of function interchange()
int a=10, b=20;
The function interchange() interchanges the values of the variables supplied to it. So the
output of the program is
Write suitable interchange() function. Also fill in the gaps of this program so that it
produces the desired output.