A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH ‘C’ LANGUAGE
: JANUARY 2005
NOTE:
1. There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions and PART TWO contains FOUR questions.
2. PART ONE is to be answered in the TEAR-OFFANSWER 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)
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 Given the following code fragment:
int ch = 20;
printf (“%d” \t %d\n”, ++ch, ch);
what will be the output of this code?
A) 21 20
B) 20 21
C) 20 20
D) 21 21
1.2 How many times following loop will be executed?
for(a = 0; a < 14 ; a++)
printf(“hello\n”);
A) 15
B) 13
C) 14
D) infinite
1.3 What is the output of the following code:
b = ++c + ++ c; if c is 10 initially
A) 20
B) 23
C) 24
D) 22
1.4 The goto statement causes control to go to
A) an operator
B) a label
C) a variable
D) a function
1.5 In an array in ‘C’, the address of element at the nth position is given by
A) Starting address + n *(size of variable)
B) Starting address + n
C) Starting address + n
D) None of the above
1.6 Macros are defined using which statement?
A) #define
B) #include
C) #if
D) #ifdef
1.7 Which one of the following does not represent a valid storage class in ‘C’?
A) automatic
B) static
C) extern
D) union
1.8 Which variable type holds at a common assigned area different data types of varying sizes at different points in time?
A) struct
B) union
C) enum
D) none of the above
1.9 For the program given below what will be the correct output?
int total;
int &sum = total;
total = 100;
printf(“sum = %d total = %d\n”, sum, total);
A) sum = 100 total = 100
B) sum = 100 total = 0
C) sum = 0 total = 100
D) none of the above
1.10 Which of the following data type is a structured data type with heterogeneous elements?
A) Array
B) Structure
C) enum
D) Pointer
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 In ‘C’ program, all variables must be declared before they are used.
2.2 Gets() and puts() functions are unformatted I/O functions.
2.3 Unless otherwise defined, a variable declared in a function is considered to be auto.
2.4 && and & operators have the same meaning in ‘C’.
2.5 We cannot create structures within structures in ‘C’.
2.6 The keyword typedef is used to create a new data type.
2.7 The identifier argv[ ] is a pointer to an array of strings.
2.8 Enumerated data types help in conserving memory.
2.9 In the case statement, label can be a floating-point number.
2.10 Auto variables defined in different functions will be independent of each other even if they have the same name.
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 Data type of conserve memory A. pointer
3.2 A function Calling itself B. loop
3.3 Address of a variable C. union
3.4 The region in a program where variable can be accessed D. malloc
3.5 Dynamic memory allocation E. recursion
3.6 A mechanism to execute a set of statements number of times F. function
3.7 Concept used for writing modular program G. argc
3.8 Command line argument H. printf
3.9 Outputting Multiple data I. #define
3.10 Preprocessor directive J. variable scope
K. stack
L. memory
M. list
N. structure
4. Each statement below has blank space to fit one of the word(s) or phrases in the list below. Enter your choice in the “tear-off” answer sheet attached to the question paper, following instructions therein. (1 x 10)
A. break B. && C. different
D. reference E. do-while F. 90
G. stack H. formal I. struct
J. union K. queue L. stdio.h
M. external N. binary O. pointer
4.1 Structure data type stores information of _________________ type.
4.2 _____________ header file defines types and macros needed for standard I/O package.
4.3 The __________ loop executes at least once.
4.4 The ______________ arguments are defined in the function declaration in the calling function.
4.5 In ‘C’ Logical AND operator is represented as ____________.
4.6 The function call using pointers is known as call by _____________.
4.7 The ____________ statement helps immediate exit from any part of the loop.
4.8 _____________ variables are also known as global variables.
4.9 A multidimensional array A[10][9] can store __________ number of elements.
4.10 In ‘C’ we can open files in the text mode or ____________ mode. For more questions papers visit www.DoeaccOnline.com, www.IgnouOnline.com
PART TWO
(Answer ALL questions)
5.
a) Write a ‘C’ program to print the largest even and largest odd number from a list of numbers entered through keyboard.
b) Write a program in ‘C’ using while loop to find factorial of a positive integer.
(8+7)
6.
a) Write a ‘C’ program for counting the number of vowels and consonants in a line of text entered from console.
b) Write a program to reverse a string using recursion.
(8+7)
7. Write a ‘C’ program that includes the following modules:
i) enter elements of two matrices.
ii) function for adding two matrices.
iii) function for multiplying two matrices.
(2+6+7)
8. You are given a singly linked list containing integer values.
i) Write a ‘C’ function to add an element at the end of list.
ii) Write a ‘C’ function to delete an element from the list, if it exists otherwise return null.
(7+8)
9. Write a ‘C’ program to create a database of maximum 50 employees with the following data:
Employee- number
Name
Age
Basic-Salary
Input the data and arrange the records on the basis of their names. After sorting display all the records and also store all the records in a file.
(15)