January, 2016
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 “OMR” answer sheet supplied with the question paper, following instructions therein. (1x10)
1.1 Function of a compiler is to
A) put together the file and functions that are required by the program
B) translate the instructions into a form suitable for execution by the program
C) load the executable code into the memory and execute them
D) allow the user to type the program
1.2 The preprocessor directives start with
A) //
B) /
C) #
D) /*
1.3 Which of the following defines a variable ‘a’ as an array of pointers to integers?
A) int *b[10], a[10];
B) int *b, a[10];
C) int b, *a[10];
D) int b, (*a)[10];
1.4 Which of the following is not an infinite loop?
A)
for (i = 1; i
< 10; i--)
printf("%d",
i);
B)
while (i <=
10) // Assume i is initialized to 1
{
printf("%d", i);
if (i = = 3)
continue;
if (i = = 6)
break;
i++;
}
C)
do // Assume i is initialized to 1
{
printf("%d", i);
if (i = = 3)
continue;
if (i = = 6)
break;
i++;
}while (i <= 10);
D)
while
(i <= 10) // Assume i is initialized to 1
{
printf("%d", i);
if (i = = 6)
continue;
if (i = = 3)
break;
i++;
}
1.5 Which of the following is the correct way to define a self-referential structure named ‘test’?A)
struct
test
{
int a;
struct test p;
};
B)
struct
test
{
int a;
struct test *p;
};
C)struct test
{
int a;
}*t;
D)
struct
*test
{
int a;
struct test p;
};
1.6 What is the output of the following code segment?
void
fn()
{
int a = 10;
static int
b = 20;
printf("a = %d
b = %d ", ++a, ++b);
}
int
main()
{
fn();
fn();
return 0;
}
A) a = 11 b = 21 a = 11 b = 21B) a = 11 b = 21 a = 12 b = 21
C) a = 11 b = 21 a = 11 b = 22
D) a = 11 b = 21 a = 12 b = 22
1.7 Consider a structure defined as follows:
struct
student
{
int rollNo, marks;
char name[30], course[30];
} s, *sp;
1.8 Which of the following is the correct way to access the members of the structure?
A) sp.marks
B) sp -> rollNo
C) student.course
D) s -> name
1.8 Which of the following statements will not dynamically allocate space to store 10 integers?
A) int a[10];
B) int *p = (int *) malloc(10 * sizeof(int));
C) int *p = (int *) calloc(10, sizeof(int));
D) none of the above
1.9 What will be the output of the following code segment?
int a
= 100, b = 74;
if
(a++ > 100 && b++ > 200)
printf("High values with a = %d b = %d\n", a,
b);
if
(a++ < 100 || b++ < 200)
printf("Low values with a = %d b = %d\n", a,
b);
A) High values with a = 101 b = 74B) Low values with a = 102 b = 75
C) High values with a = 102 b = 75
D) Low values with a = 101 b = 74
1.10 Which of the following can be used as a variable name?
A) no of students
B) char
C) 7th
D) myName
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the “OMR” answer sheet supplied with the question paper, following instructions therein. (1x10)
2.2 There is no difference between '\0' and '0'. (F)
2.3 The fprintf() function can be used to display the output on the screen. (T)
2.4 A float constant cannot be used as a case constant in a switch statement.
2.5 The statement void p; is valid.(F)
2.6 while (0); is an infinite loop. (F)
2.7 If char *p = "Structured Programming", then p[5] is 'c'. (T)
2.8 A function can have any number of return statements. (F)
2.9 In a union, space is allocated to every member individually. (F)
2.10 An algorithm is a graphical representation of the logic of a program. (F)
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 “OMR” answer sheet supplied with the question paper, following instructions therein. (1x10)
X Y3.1 A necessary function (J) A. ++x
3.2 Pre-decrement (I) B. Node points to the next
3.3 Typecasting (H) C. test(a, test(a + b))
3.4 Call by reference (G) D. remove()
3.5 Linked list (B) E. fscanf()
3.6 Recursion (C) F. ~
3.7 Bitwise operator (F) G. fn(&a)
3.8 Removes dynamically allocated space (K) H. (float)
3.9 Function to read the contents of a file (E) I. --m
3.10 Comparing contents of two character J. main()
arrays str1 and str2 (L)
K. delete()
L. strcmp(str1, str2)
M. fn(a)
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 “OMR” answer sheet supplied with the question paper,following instructions therein. (1x10)
D. '\0' E. "\0" F. (*p).name
G. fn(int q, char c) H. register I. fn(12, 'n')
J. {} K. logical L. Header
M. relational
4.1 A file can be opened for both reading and writing using _____A___ mode.
4.2 The preferred storage class if fast access is required for a variable is ____(H)____.
4.3 A function call for a function with the declaration void fn(int x, char c); is ____(I)____.
4.4 __ (B)______ is the file automatically connected to the keyboard for every program.
4.5 ___(D)____ is the character stored in the pointer value of the last node of a linked list.
4.6 The ___(K)____ operators are used to compare the values of integers.
4.7 If *pf is a pointer to float, then ++pf will increment its value by ____(C)____.
4.8 The brackets used to mark the boundaries of a block are ____(J)____.
4.9 Relevant ____(L)____ files have to be included in a program for library functions to work.
4.10 p -> name can be written as ____(F)____.
PART TWO
(Answer any FOUR questions)
5.a) Write a program to calculate number of vowels (a, e, i, o, u) separately in the entered string.
b) Write a program to find the power of number using function.
c) Draw a flowchart to print the factorials of numbers from 1 to n, where n is entered by user.
(6+5+4)
6.
a) Write a program to copy a file into another file.
b) Write a function to print the sum of the following series:
1 + 22 + 33 + … + nn
where n is passed as an argument to the function.
c) Write a function to read a two dimensional matrix along with the number of rows and columns in
it, from the user. The contents of the array and the number of rows and columns should be passed back to the calling function.
(5+5+5)
7.
a) How does passing an array as an argument to a function differ from call by value?
b) Differentiate between the following:
i) if and switch statements
ii) while and do..while loops
using the switch statement.
(4+4+7)
8.
a) Write a program having a recursive function to calculate the factorial of a number. In the main()
function, read the value of the number and then using the recursive function display the result.
b) Write a program to create a structure Employee having empCode, name, department, address
and salary as its members. Read the details for 10 employees and then display them.
(6+9)
9.
a) What is the output of the following code segments?
i) int m = -10, n = 20;
n = (m < 0) ? 0 : 1;
printf("%d %d", m, n);
Output :
-10,0
ii) int x = 7538;
printf("%d %d\n", x % 100, x / 10);
Output :
Garbage and 753
iii) char c = 'f';
switch (c) {
default: printf("unknown colour ");
case 'r': case 'R': printf("Red ");
case 'g': case 'G': printf("Green "); break;
case 'b': case 'B': printf("Blue");
}
Output :
unknown colour Red Green
iv) char a[] = "Hello", *p = a;
while (*p != '\0')
printf("%s\n", p++);
Output:
Hello
ello
llo
lo
o
b) Define the structure of a node of a singly linked list and use it to write a function to count the
number of nodes in a singly linked list. The function should accept a pointer to the first node of
the list and it should return the number of nodes in the list.
([2+2+2+3]+6)
No comments:
Post a Comment