edited by
476 views
0 votes
0 votes
#include<stdio.h>
struct 
{
    short x[5];
    union 
    {
        float y;
        long z;
    }u;
}t;
int main() 
{
    printf("short=%d\n",sizeof(short));
    printf("float=%d\n",sizeof(float));
    printf("long=%d\n",sizeof(long));
    printf("%d",sizeof(t));
    return 0;
}

Answer should be 14 but why the answer is 16 ?

Note : short : 2 bytes , float : 4 bytes , long : 4 bytes

edited by

1 Answer

0 votes
0 votes
Please verify the question before posting it.

Its a basic question in which they only want to know if candidate knows the UNION storage allocation rule or not.

14 is correct answer for your question while in original question they mentioned long size 8 bytes and hence answer was 18 bytes correspondingly.

2*5+8=18 bytes

Related questions

0 votes
0 votes
0 answers
2
shubham0109 asked Feb 8, 2019
436 views
Is the form for ISRO CSE out? If it is please provide the link
4 votes
4 votes
0 answers
3
syncronizing asked Feb 5, 2019
462 views
Will ISRO 2019 recruit this year? till now there is no information about ISRO 2019 form.Please share if you have information regarding it.
5 votes
5 votes
2 answers
4
Souvik33 asked Jan 15, 2023
1,135 views
Consider the function func shown below: int func(int num) { int count = 0; while (num) { count++; num>>= 1; } return (count); }The value returned by func(-435) is:69Will ...