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

application attempts to perform an operation?

0 Answers  


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

0 Answers  


#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b); }

7 Answers   Infosys,


Write a code to generate divisors of an integer?

0 Answers   Ericsson,


implement general tree using link list

1 Answers   Wipro,






1.write a program to merge the arrays 2.write efficient code for extracting unique elements from a sorted list of array?

3 Answers   Qualcomm,


how to print this sereis 2 4 3 6 5..........?

3 Answers  


difference between string and array?

6 Answers  


Explain enumerated types.

0 Answers  


difference between c and c++?

2 Answers  


1)what is the error in the following stmt where str is a char array and the stmt is supposed to traverse through the whole character string str? for(i=0;str[i];i++) a)There is no error. b)There shud be no ; after the stmt. c)The cond shud be str[i]!='\0' d)The cond shud be str[i]!=NULL e)i shud be initialized to 1

4 Answers  


How can I implement sets or arrays of bits?

0 Answers  


Categories