Consider the following program #include <stdio.h> int main() { int x = 1;…

ISRO Scientist/Engineer SC 2018Modified — slightly modified from the official paper; see the solution

Consider the following program

#include <stdio.h>

int main()
{
    int x = 1;
    printf("%d", *(char *)&x);
    return 0;
}

Assuming required header files are included and if the machine in which this program is executed is little-endian, then the output will be

  1. A.

    0

  2. B.

    99999999

  3. C.

    1

  4. D.

    unpredictable

Attempted by 1116 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…