Q)What is the difference between union and structure?
Answer)
Structure
1.We can access all the members of structure at anytime
Union
1.Only One member Can be accessed at anytime
Structure
2.Memory is allocated for all variables
Union
2.Allocates memory for variable whichVariable
require more memory
Structure
3.All members of Structur can be initialized
Union
3.Only the first member of a union can be
initialized
Structure
4."Struct" Keyword is Used to declare structure
Union
4."union" Keyword is used to declare union
Structure
5.All member has its own storage location
Union
5.All members are stored in same location
Answer)
Structure
1.We can access all the members of structure at anytime
Union
1.Only One member Can be accessed at anytime
Structure
2.Memory is allocated for all variables
Union
2.Allocates memory for variable whichVariable
require more memory
Structure
3.All members of Structur can be initialized
Union
3.Only the first member of a union can be
initialized
Structure
4."Struct" Keyword is Used to declare structure
Union
4."union" Keyword is used to declare union
Structure
5.All member has its own storage location
Union
5.All members are stored in same location
0 comments:
Post a Comment
Dont Forget for Commets