GATE 2017 (Session 1) Computer Science and Information Technology (CS) Questions with Solutions

GATE 2017 (Session 1)

64 questions

MCQ 44 · NAT 201-mark 30 · 2-mark 34

Questions 61–64 of 64

Q62Intermediate Code Generation2 marksNAT
Consider the expression ( a-1)* (((b + c) / 3) + d)) . Let X be the minimum number of registers required by an optimal code generation (without any register spill) algorithm for a load/store architecture in which (i) only loads and store instructions can have memory operands and (ii) arithmetic instructions can have only register or immediate operands. The value of X is _________.

Q63Array and Pointer2 marksNAT
Consider the following C program.
 #include <stdio.h>
#include <string.h>
void printlength (char *s, char *t) {
 unsigned int c = 0;
 int len = ((strlen(s) - strlen (t)) > c) ? strlen(s): strlen(t);
 printf ("%d\n", len);
}
void main ( ) {
 char *x = "abc";
 char *y ="defgh"; 
 printlength (x,y);
}
Recall that strlen is defined in string.h as returning a value of type size_t, which is an unsigned int. The output of the program is _____________.

Q64Cache Memory2 marksNAT
A cache memory unit with capacity of N words and block size of B words is to be designed. If it is designed as a direct mapped cache, the length of the TAG field is 10 bits. If the cache unit is now designed as a 16-way set-associative cache, the length of the TAG field is ______bits.

Q65Function2 marksNAT
The output of executing the following C program is ________.
 #include <stdio.h>
int total (int v) {
    static int count = 0;
    while (v) {
        count += v & 1;
        v >>= 1;
    }
    return count;
 }
void main ( ) {
static int x = 0;
int i = 5;
for (; i> 0; i--) {
x=x + total (i) ; 
}
printf ("%d\n", x) ; }