Question 1
Consider the following declaration:
int a, *b=&a, **c=&b;
The following program fragment
a=4;
**c=5;
does not change the value of a
assigns address of c to a
assigns the value of b to a
assigns 5 to a
Question 2
Consider the following C program.
#include<stdio.h>
void mystery(int *ptra, int *ptrb)
{
int *temp;
temp = ptrb;
ptrb = ptra;
ptra = temp;
}
int main()
{
int a=2016, b=0, c=4, d=42;
mystery(&a, &b);
if (a < c)
mystery(&c, &a);
mystery(&a, &d);
printf("%d", a);
}
The output of the program _____________ Note : This question was asked as Numerical Answer Type.
2016
0
4
8
Question 3
int main() { int array[5][5]; printf("%d",( (array == *array) && (*array == array[0]) )); return 0; }
Question 4
int main() { int a = 300; char *b = (char *)&a; *++b = 2; printf("%d ",a); return 0; }Consider the size of int as two bytes and size of char as one byte. Predict the output of the following code . Assume that the machine is little-endian.
Question 5
Consider the following function implemented in C:
void printxy(int x, int y)
{
int *ptr;
x = 0;
ptr = &x;
y = *ptr;
*ptr = 1;
printf("%d,%d", x, y);
}
The output of the printxy(1,1) is
0,0
0,1
1,0
1,1
Question 6
Consider the following snippet of a C program. Assume that swap(&x, &y) exchanges the contents of x and y.
int main()
{
int array[] = {3, 5, 1, 4, 6, 2};
int done = 0;
int i;
while (done == 0)
{
done = 1;
for (i = 0; i <= 4; i++)
{
if (array[i] < array[i+1])
{
swap(&array[i], &array[i+1]);
done = 0;
}
}
for (i = 5; i >= 1; i--)
{
if (array[i] > array[i-1])
{
swap(&array[i], &array[i-1]);
done = 0;
}
}
}
printf("%d", array[3]);
}
The output of the program is _____. Note: This question appeared as Numerical Answer Type.
1
2
3
4
Question 7
Question 8
‘ptrdata’ is a pointer to a data type. The expression *ptrdata++ is evaluated as (in C++) :
Depends on compiler
(*ptrdata)++
*(ptrdata)++
*(ptrdata++)
Question 9
Consider the following table
A. Activation record | p. Linking loader |
B. Location counter | q. Garbage collection |
C. Reference counts | r. Subroutine call |
D. Address relocation | s. Assembler |
Matching A, B, C, D in the same order gives :
p, q, r, s
q, r, s, p
r, s, q, p
r, s, p, q
Question 10
What does the following C-statement declare? int (*f) (int*);
A function that takes an integer pointer as argument and returns an integer
A function that takes an integer as argument and returns an integer pointer
A pointer to a function that takes an integer pointer as argument and returns an integer
A function that takes an integer pointer as argument and returns a function pointer
There are 43 questions to complete.