0 votes 0 votes What is the Output of Following Program Snippet ? #include <stdio.h> struct Key{ int X; char P; }; int main() { struct Key Values[] = {10,'A',20,'B',30,'C',40,'D'}; printf("%d",sizeof(Values)); } Explain your Answer .. Programming in C programming-in-c + – Na462 asked Jul 3, 2018 Na462 257 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
4 votes 4 votes Consider int has 2B and Char has 1B normally Size of Structure = 3 Bytes only ===> to make structure alignment, size of the structure should be divided by size of the highest size member ===> Size of Structure = 4 Bytes. Values is a collection of 4 Structures ==> size of 'values' variable = 4*4 = 16 Bytes Consider int has 4B and Char has 1B normally Size of Structure = 5 Bytes only ===> to make structure alignment, size of the structure should be divided by size of the highest size member ===> Size of Structure = 8 Bytes. Values is a collection of 4 Structures ==> size of 'values' variable = 4*8 = 32 Bytes. For More information read https://www.geeksforgeeks.org/structure-member-alignment-padding-and-data-packing/ Shaik Masthan answered Jul 3, 2018 Shaik Masthan comment Share Follow See all 0 reply Please log in or register to add a comment.