Struct(s)
{
int a;
long b;
}
Union (u)
{int a;
long b;
}
Print sizeof(s)and sizeof(u) if sizeof(int)=4 and
sizeof(long)=4

Answers were Sorted based on User's Feedback



Struct(s) { int a; long b; } Union (u) {int a; long b; ..

Answer / jack

I assume above code to be correctly written as below:
struct s
{
int a;
long b;
}
Union u
{int a;
long b;
}
sizeof(s)= 8
sizeof(u) = 4

Is This Answer Correct ?    9 Yes 0 No

Struct(s) { int a; long b; } Union (u) {int a; long b; ..

Answer / vikraman85

Size fo strucure wil be the total bytes of the datatypes
inside it..
so,4+4=8;
For unions the size wi be the size of the datatype whose
memory is high,.
so,its 4,.

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More C Interview Questions

what is pointer ? what is the use of pointer?

6 Answers   Infosys,


How can I read a binary data file properly?

0 Answers  


What is null pointer constant?

0 Answers  


Explain what is the most efficient way to store flag values?

0 Answers  


how to print "hai" in c?

13 Answers   TCS,






Program to find the value of e raised to power x using while loop

5 Answers   IBM, N Tech,


Can a file other than a .h file be included with #include?

0 Answers   Aspire, Infogain,


How can I make sure that my program is the only one accessing a file?

0 Answers  


Differentiate Source Codes from Object Codes

1 Answers  


What is the ANSI C Standard?

0 Answers   Celstream,


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

0 Answers   InterGraph,


How to reverse a string using a recursive function, without swapping or using an extra memory?

31 Answers   Cisco, Mind Tree, Motorola, Ophio, Sony, TCS, Wipro,


Categories