GATE 2000 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2000

54 questions

MCQ 541-mark 54

Questions 26–30 of 54

Q26Array and Pointer1 markMCQ−0.33 if wrong
Consider the following C declaration:
 struct { 
    short x[5];  
    union { 
        float y; 
        long z; 
    } u;
 } t;

Assume that the objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment consideration, is:

Q27Array and Pointer1 markMCQ−0.33 if wrong
Aliasing in the context of programming languages refers to

Q28Array and Pointer1 markMCQ−0.33 if wrong
The most appropriate matching for the following pairs is:

X:m = malloc(5); m = NULL;1:using dangling pointersY:free(n); n -> value = 5;2:using uninitialized pointersZ:char *p , *p = ’a’ ; 3:lost memory\begin{array}{|ll|ll|}\hline X: & \text{m = malloc(5); m = NULL;} & 1: & \text{using dangling pointers} \\\hline Y: & \text{free(n); n -> value = 5;} & 2: & \text{using uninitialized pointers} \\\hline Z: & \text{char *p , *p = 'a' ; } & 3: & \text{lost memory} \\\hline \end{array}

Q29Array and Pointer1 markMCQ−0.33 if wrong
The following C declarations:
 struct node { 
    int i;
    float j;
 };
 struct node *s[10];
define s to be:

Q30Array1 markMCQ−0.33 if wrong
Suppose you are given an array s[1....n] and a procedure reverse (s, i, j) which reverses the order of elements in s between positions i and j (both inclusive). What does the following sequence do, where 1 ⩽k⩽\leqslant k \leqslant n:
 reverse (s, 1, k);
 reverse (s, k+1, n);
 reverse (s, 1, n);