0% found this document useful (0 votes)
118 views2 pages

Quiz 3: Computer Programming (MA511)

The document contains a quiz on computer programming with 5 multiple choice questions. Question 1 has 2 parts that ask about the output of a C code sample that assigns and prints values to 5 integer variables. Question 2 asks about the output of a program that passes a 2D array to a function and prints one of its elements. Question 3 asks about the output of a program that gets and prints character input, excluding or including the character 'Q'. Question 4 has multiple parts about operations on a binary search tree given a series of node values. Question 5 asks to write a subroutine to implement a circular doubly linked list given a skeletal C program structure.

Uploaded by

Naveen Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views2 pages

Quiz 3: Computer Programming (MA511)

The document contains a quiz on computer programming with 5 multiple choice questions. Question 1 has 2 parts that ask about the output of a C code sample that assigns and prints values to 5 integer variables. Question 2 asks about the output of a program that passes a 2D array to a function and prints one of its elements. Question 3 asks about the output of a program that gets and prints character input, excluding or including the character 'Q'. Question 4 has multiple parts about operations on a binary search tree given a series of node values. Question 5 asks to write a subroutine to implement a circular doubly linked list given a skeletal C program structure.

Uploaded by

Naveen Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Quiz 3: Computer Programming (MA511)

M.Sc. (M&C), Semester: Aug-Nov 2008-2009


Dept. of Mathematics, IIT Guwahati
Date: November 14, 2008 Time: 4:00AM - 5:30AM
Attempt All Questions Marks: 30

1. Output of the following code will be ? [5]

main (){
int a, b, c, d, e;
a = (b = (c = (d = (e = 0))));
printf (“%d %d %d %d %d\n”, a, b + +, c − −, d = 10, e+ = 3);
printf (“%d %d %d %d %d\n”, a, b, c, d = e, e+ = d);
a = b = c = d = e = 0;
printf (“%d %d %d %d %d\n”, a, + +b, − −c, d = 10, e+ = 3);
printf (“%d %d %d %d %d\n”, a, b, c, d+ = e, e = d);
}

2. Output of this program will be ? [4]

main(){
void function(int b[ ][3]){
int a[3][3]= {{1,2,3}, {4,5,6}, {7,8,9}};
++ b;
function(a);
b[1][1] =9;
printf(“%d” , a[2][1]);
}
}
3. What will be the output of the following code if inputs are given any character (i) excluding
and (ii) including ‘Q’ and why ? [4]

main(){
char ch;
do{
switch(ch = getchar()){
default : putchar(ch); break;
case ‘Q’ : ;
}
}while (ch != ’Q’);
}
4. Draw binary search tree where key values of the nodes are given in the following or-
der: 15, 20, 5, 10, 11, 2, 3, 7, 8, 1, 30, 20 , 200 , 10 . (i) Trace path for searching the target
keys: 1, 2, 9, 14. (ii) What is the hight of the tree ? (iii) How many extra node do
you need for making the tree complete ? (iv) Use formula for calculating the total
number of nodes assume the tree is complete. [3+2+1+2+2]

5. Write a subroutine to implement a doubly linked list as a circular list without us-
ing recursion. Assign appropriate links over the doted place in the following skeletal
structure of C program such that doubly circular list will be maintained. [4+3]

main(){
node *p, *q, *r, *s;
p = (node *) malloc(sizeof(node));
q = (node *) malloc(sizeof(node));
typedef struct list {
r = (node *) malloc(sizeof(node));
struct list *prev;
s = (node *) malloc(sizeof(node));
int data;
p→data = 12;
struct list *next;
q→data = 11;
} node;
r→data = 14;
s→data = 5;
..
.
}

You might also like