GATE Solved Paper 2017-19 - GATE 2018

36. Consider the following C program:
#include
void fun 1 (char *s1, char *s2) {
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
Void fun2 (char **s1, char **s2) {
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
int main () {
char *str1 = “Hi”, *str2 = “Bye”;
fun1 (str1, str2);
printf(“%s %s”, str1, str2);
fun2 (&str1, &str2);
printf(“%s %s”, str1, str2);
return 0;
}
The output of the program above is

  • Option : A
  • Explanation :
    fun1(char *s1, char *s2)
    function scope is local, so the value changed So the affect actual parameters. SO the values will be ‘Hi Bye’.
    fun2(char **s1, char **s2)
    In this function value is pointer to pointer, so it changes pointer of the actual value. So values will be ‘Bye Hi’
Cancel reply
Cancel reply

39. The size of the physical address space of a processor is 2P bytes. The word length is 2W bytes. The capacity of cache memory is 2N bytes. The size of each cache block is 2M words. For a K-way set-associative cache memory, the length (in number of bits) of the tag field is

  • Option : B
  • Explanation :
    MM space = 2P bytes
    Physical Address (PA) size = P bits
    CM size = 2N bytes
    Block size 2M words
    2M words*2W bytes/word
    2M+W bytes
    Number of lines = (CM size)/Block size ⇒ 2N/(2M+W)
    ⇒ 2N-M-W
    Number of sets = (Number in cm)/P-way
          = 2N-M-W/K
    The Address format

    ⇒ (N-M-W-log2K)
    ∴ Tag size
    ⇒ P-(N-M-W-log2K)
    ⇒ P-N+log2K)
Cancel reply
Cancel reply