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 the use of a static variable in c?

0 Answers  


Difference between exit() and _exit() function?

0 Answers  


How will you divide two numbers in a MACRO?

0 Answers   Apps Associates,


plz answer..... a program that reads non-negative integer and computes and prints its factorial

2 Answers  


C program to perform stack operation using singly linked list

3 Answers  






What is the purpose of realloc()?

0 Answers  


How are structure passing and returning implemented?

0 Answers  


write a string copy function routine?

2 Answers  


How can I set an array's size at run time?

9 Answers  


Here is a neat trick for checking whether two strings are equal

0 Answers  


Explain how do you determine a file’s attributes?

0 Answers  


What is the purpose of & in scanf?

0 Answers  


Categories