What will be the output of the following 'C' code on a 64-bit computer? #…

2026

What will be the output of the following 'C' code on a 64-bit computer?

# include <stdio.h>

union sti

{

int x;

char y;

};

int main ( )

{

union sti s;

printf ("%d", sizeof (s));

return 0;

}

  1. A.

    9

  2. B.

    5

  3. C.

    4

  4. D.

    8

Attempted by 174 students.

Show answer & explanation

Correct answer: C

In C, a union shares memory for all its members. The size of the union is determined by its largest member. Here, the largest member is int x, which typically takes 4 bytes on a standard 64-bit system. The char y takes 1 byte. Thus, sizeof(s) returns 4.

Explore the full course: Up Lt Grade Assistant Teacher 2025