Question 1
If n has 3, then the statement a[++n]=n++;
assigns 3 to a[5]
assigns 4 to a[5]
assigns 4 to a[4]
what is assigned is compiler dependent
Question 2
The for loop
for (i=0; i<10; ++i)
printf("%d", i&1);
prints:
0101010101
0111111111
0000000000
1111111111
Question 3
The output of the following program is
main()
{
static int x[] = {1,2,3,4,5,6,7,8}
int i;
for (i=2; i<6; ++i)
x[x[i]]=x[i];
for (i=0; i<8; ++i)
printf("%d", x[i]);
}
1 2 3 3 5 5 7 8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
1 2 3 5 4 6 7 8
Question 4
Consider the following program fragment i=6720; j=4; while (i%j)==0 { i=i/j; j=j+1; } On termination j will have the value
4
8
9
6720
Question 5
Consider the following program fragment
if(a > b)
if(b > c)
s1;
else s2;
s2 will be executed if
a <= b
b > c
b >= c and a <= b
a > b and b <= c
Question 6
What will be output of following program?
#include <stdio.h>
union Data {
int i;
float f;
};
int main() {
union Data d;
d.i = 10;
d.f = 20.5;
printf("%d", d.i);
return 0;
}
10
20
Garbage value
Compilation error
Question 7
Consider the following statements
#define hypotenuse (a, b) sqrt (a*a+b*b); The macro call hypotenuse(a+2,b+3);
Finds the hypotenuse of a triangle with sides a+2 and b+3
Finds the square root of (a+2)2 and (b+3)2
Is invalid
Find the square root of 3*a + 4*b + 5
Question 8
In a lottery scheduler with 40 tickets, how we will distribute the tickets among 4 processes and such that each process gets 10%, 5%, 60% and 25% respectively?
P1 P2 P3 P4
a) 12 4 70 30
b) 7 5 20 10
c) 4 2 24 10
d) 8 5 40 30
a
b
c
d
Question 9
Suppose a system contains n processes and system uses the round-robin algorithm for CPU scheduling then which data structure is best suited for ready queue of the process
stack
queue
circular queue
tree
Question 10
A certain population of ALOHA users manages to generate 70 request/sec. If the time is slotted in units of 50 msec, then channel load would be
4.25
3.5
350
450
There are 80 questions to complete.