1
GATE CSE 2018
MCQ (Single Correct Answer)
+1
-0.3
Consider the following C program.
#include< stdio.h >
struct Ournode{
 char x,y,z;
};
int main(){
 struct Ournode p = {'1', '0', 'a'+2};
 struct Ournode *q = &p;
 printf ("%c, %c", *((char*)q+1), *((char*)q+2));
 return 0;
}
The output of this program is:
A
0, c
B
0, a+2
C
'0', 'a+2'
D
'0', 'c'
2
GATE CSE 2018
Numerical
+1
-0
Consider the following C program:
#include < stdio.h >
  int counter = 0;
  int calc (int a, int b) {
  int c;
  counter++;
  if (b==3) return (a*a*a);
  else {
    c = calc(a, b/3);
    return (c*c*c);
 }
}
int main (){
  calc(4, 81);
  printf ("%d", counter);
}
The output of this program is _____.
Your input ____
3
GATE CSE 2018
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
#include< stdio.h >
void fun1(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
A
Hi Bye Bye Hi
B
Hi Bye Hi Bye
C
Bye Hi Hi Bye
D
Bye Hi Bye Hi
4
GATE CSE 2018
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C code. Assume that unsigned long int type length is 64 bits.
unsigned long int fun(unsigned long int n){
     unsigned long int i, j = 0, sum = 0;
     for (i = n; i > 1; i = i/2) j++;
     for ( ; j > 1; j = j/2) sum++;
     return(sum);
}
The value returned when we call fun with the input $${2^{40}}$$ is
A
4
B
5
C
6
D
40
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12