## Wednesday, 13 July 2016

### July, 2012 M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH ‘C’ LANGUAGE

#### July, 2012M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH ‘C’ LANGUAGE

NOTE:
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
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. (1x10)

1.1 Which of the following is not an unconditional control statement in ‘C’?
A) break
B) continue
C) exit()
D) while

1.2 What will be the output of the following program?
Main()
{ int x = 5;
While ( x = = 1)
x = x -1;
printf ( “ %d\n”, x);
}
A) 5
B) 4
C) 0
D) syntax error

1.3 Which of the following is not a proper storage class in ‘C’?
A) auto
B) dec
C) static
D) extern

1.4 Which of the following is a wrong pointer declaration?
A) int *int(a);
B) int *x, *y;
C) float *aptr;
D) int *x, float *y;

1.5 The value of S in the segment char s = “ MICROPROCESSOR” is
A) P
B) O
C) R
D) None of the above

1.6 Function putchar() displays
A) one word at a time on the screen
B) one character at a time
C) result on the screen
D) None of the above

1.7 The sqrt() function is available in
A) conio.h
B) string.h
C) math.h
D) graphic.h

1.8 If ‘a’ is an integer variable, then a = 5/2 will return a value
A) 2.5
B) 2
C) 2.000000
D) 2.500000

1.9 Which of the following a not a basic data type used in C language?
A) double
B) float
C) char
D) array

1.10 pow(x,y) is used to
A) power of yx
B) power of xy
C) logarithm of x on the base y
D) Such function does not exist

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 break statement is used to exit from a statement block in a switch statement.
2.2 Recursion cannot call a function itself.
2.3 An array is a group of related data item that share a common memory location in RAM.
2.4 In the declaration int(*p)() p is a pointer to a function that returns an integer.
2.5 If m = 5, ++m + ++m is equal to 12.
2.6 The memory required in structure is less than union.
2.7 A function in ‘C’ must have at least one argument.
2.8 The programming language happens to be the high level language with some assembly
language features.
2.9 In C functions the actual expressions / parameters are passed on to formal parameters
using the method of call by value result
2.10 In C the graphics may be used to add graphical features to the program.

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                                                       Y

3.1 exit(0) in a ‘C’ program                                    A. Increase or decrease of pointer value
represents
3.2 The difference in ‘a’ and “a” is                        B. derived data type
3.3 pointer arithmetic refers to                               C. Termination of a program
3.4 int *mptr, m=25; mptr=&m performs              D. Converts a data type to another data
type
3.5 Function that detects error in file                     E. User define data type
accessing
3.6 Array is a                                                         F. Initializes the pointer
3.7 The statement block in while is                      G. f=(X < 0)? 0 : 1
executed
3.8 Typecasting                                                      H. ferror()
3.9 Formatted print is used to                                I. Perform operations in string
3.10 string.h is used to                                          J. Take printout in special format
K. ‘a’ is a single character constant and
“a” is a string character constant
L. When the values of the condition is true
M. Bitwise operator

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)
A. static                              B. calloc()                             C. main()
D. char                               E. free()                                 F. Right to left
G. Close and                      H. Left to right                      I. register
disconnect the file
from
J. atoi()                               K. putpanel()                         L. stdin
M. stdout

4.1 ________ is the function to convert a ASCII character into an integer.
4.2 In C an array of character is known as ________.
4.3 The line from which a program execution begins is ________.
4.4 ________ function is used to release the memory allotted in dynamic memory allocation.
4.5 The dynamic memory allocation function are ________ and malloc().
4.6 p++ has associativity ________.
4.7 The use of ________ is considered unstructured programming.
4.8 The storage class ________ has global visibility.
4.9 The standard file, in ‘C’, ________ is connected to screen.
4.10 ________ is used to draw a point on the monitor screen in given coordinate position.

#### PART TWO(Answer any FOUR questions)

5.
a) Make the flow chart to solve the following cosine series.
S = 1 – x2/ 2! + x4/ 4! – x6/ 6! + … 100 terms
b) What is meant by formatted output? Mention the output of the following commands.
int n = 28;
i) printf ( “% 5d,”n);
Print 28 followed by 5 space from left margin.
ii) printf ( “%+5d”, n);
Print 28 followed by 5 space with = symbol from left margin.
iii) printf ( “%+5d”, n);
Print 28 followed by 5 space with = symbol from left margin.
c) Write a recursive function to compute factorial of a number.
(5+5+5)

6.
a) Write a ‘C’ program to read an array of names and to sort them in alphabetical order.
b) What are different storage classes in ‘C’? Explain each.
(7+8)
7.
a)Write a program to compute the following series:
x + x3 / 3! + x5/ 5! + …
To a given accuracy for x from 00 to 1800 in the steps of 100, use a inbuilt function FACT(n) to compute the factorial.
b) What is meant by structure data type? How do we reference the elements of a structure?
Give example of how a value of a structure can be assigned to another structure.
(8+7)

8.
a)What do you mean by a pointer variable? Write a function in ‘C’, using pointers for the array of elements, for sorting the elements.
b) Define a structure of employees of an organization with the following fields:
Empno, Empname, Date_of_joining, Salary, Department
Write a program which accepts names of ten employees and print them on the screen.
(8+7)

9.
a) What are preprocessor directions? Why do we need them? Explain various preprocessor
directives.
b) Give an example of
i) Switch statement
ii) Conditional expression
iii) Nesting of loops
iv) Dynamic memory allocation
(7+8)