+ 6

Why is the size of union here 40?

#include <stdio.h> union uTemp{ double a; int b[10]; char c; }u; int main() { printf("%d\n",sizeof(u)); return 0; }

20th Jan 2019, 6:17 PM
Zhenis Otarbay
Zhenis Otarbay - avatar
3 Respostas
+ 3
Size of union = Size of largest data type. Here the largest data type is array int b[10] whose size is 4x10 = 40 (size of int x number of elements)
20th Jan 2019, 6:33 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 2
We know that 4 is a int no and here it is give that int b[10] so the result is found 4×10=40 and 10 =size of array
26th Mar 2019, 2:34 AM
Priyavandana Kumari
Priyavandana Kumari - avatar
+ 1
40 bytes
21st Apr 2019, 1:29 PM
Chetan Patil