C Programming :: Structures, Unions, Enums - Discussion
Home > C Programming > Structures, Unions, Enums > MCQs Questions Discussion
20 / 43
What will be the size of these structures?
#include <stdio.h>
struct S1 {
char c;
int i[2];
double v;
} SA1;
struct S2 {
double x;
int i[2];
char c;
} SA2;
int main()
{
printf("\n sizeof S1 %d : Sizeof S2 %d ",sizeof(SA1),sizeof(SA2));
return 0;
}
Note:char takes 1 byte, int takes 4 bytes, double takes 8 bytes
#include <stdio.h>
struct S1 {
char c;
int i[2];
double v;
} SA1;
struct S2 {
double x;
int i[2];
char c;
} SA2;
int main()
{
printf("\n sizeof S1 %d : Sizeof S2 %d ",sizeof(SA1),sizeof(SA2));
return 0;
}
Note:char takes 1 byte, int takes 4 bytes, double takes 8 bytes
Asizeof S1 12 : Sizeof S2 12
Bsizeof S1 20 : Sizeof S2 20
Csizeof S1 13 : Sizeof S2 13
DCompilation Error
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
No Discussion on this question yet!