Sail E0 Webinar

MCQs

Total Questions : 73 | Page 4 of 8 pages
Question 31. Comment on the output of this C code?    int main()    {        int i, n, a = 4;        scanf("%d", &n);        for (i = 0; i < n; i++)            a = a * 2;    }
  1.    Logical Shift left
  2.    No output
  3.    Arithmetic Shift right
  4.    bitwise exclusive OR
 Discuss Question
Answer: Option B. -> No output


None.


Question 32. What is the output of this C code?    int main()    {        int a = 2;        if (a >> 1)           printf("%d\n", a);    }
  1.    0
  2.    1
  3.    2
  4.    No output
 Discuss Question
Answer: Option C. -> 2


None.


Question 33. What is the output of this C code?    void main()    {        int x = 97;        int y = sizeof(x++);        printf("x is %d", x);    }
  1.    x is 97
  2.    x is 98
  3.    x is 99
  4.    Run time error
 Discuss Question
Answer: Option A. -> x is 97


None.


Question 34. What is the output of this C code?    void main()    {        int x = 4;        int *p = &x;        int *k = p++;        int r = p - k;        printf("%d", r);    }
  1.    4
  2.    8
  3.    1
  4.    Run time error
 Discuss Question
Answer: Option C. -> 1


None.


Question 35.

What is the output of this C code?    void main()    {        int x = 4, y, z;        y = --x;        z = x--;        printf("%d%d%d", x, y, z);    }

  1.    3  2  3
  2.    2  2  3
  3.    3  2  2
  4.    2  3  3
 Discuss Question
Answer: Option D. -> 2  3  3


None.


Question 36. What is the output of this C code?    void main()    {        int a = 5, b = -7, c = 0, d;        d = ++a && ++b || ++c;        printf("\n%d%d%d%d", a, b, c, d);    }
  1.    6  -6  0  0
  2.    6  -5  0  1
  3.    -6  -6  0  1
  4.    6  -6  0  1
 Discuss Question
Answer: Option D. -> 6  -6  0  1


None.


Question 37. What is the output of this C code?    int main()    {        int x = -2;        x = x >> 1;        printf("%d\n", x);    }
  1.    1
  2.    -1
  3.    2 ^ 31 "“ 1 considering int to be 4 bytes
  4.    Either (b) or (c)
 Discuss Question
Answer: Option B. -> -1


None.


Question 38. What is the output of this C code?    void main()    {        int a = -5;        int k = (a++, ++a);        printf("%d\n", k);    }
  1.    -3
  2.    -5
  3.    4
  4.    Undefined
 Discuss Question
Answer: Option A. -> -3


None.


Question 39. What is the output of this C code?    int main()    {        int x = 2;        x = x
  1.    4
  2.    1
  3.    Depends on the compiler
  4.    Depends on the endianness of the machine
 Discuss Question
Answer: Option A. -> 4


None.


Question 40. What is the output of this C code?    int main()    {        if (~0 == 1)            printf("yes\n");        else            printf("no\n");    }
  1.    Yes
  2.    No
  3.    Compile time error
  4.    Undefined
 Discuss Question
Answer: Option B. -> No


None.


Latest Videos

Latest Test Papers