what are the advantages & disadvantages of unions?
Answers were Sorted based on User's Feedback
Answer / vishnu nayak
Union occupy same memory area for different members in a
union.
Same are is allocated for different data types of the
members of union
eg:
union
{
int a;
char c;
float f;
}temp;
Size of Float will be size of union.
same memory is used for char and int as well.
Advantages: Memory consumption is less.
Disadvanteges: if one of the member variable is updated the
it will be reflected in the remaining 2 variables.
| Is This Answer Correct ? | 62 Yes | 18 No |
Answer / vadivelt
Main disadvantage is, all the union member variables cannot
be initialised or used with different values at a time.
| Is This Answer Correct ? | 45 Yes | 14 No |
What is the difference between fread buffer() and fwrite buffer()?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
How can variables be characterized?
what is pointer?
13 Answers HCL, TCS,
Write a program that takes a 5 digit number and calculates 2 power that number and prints it
5 Answers ABS, Accenture, HCL, Infosys, Infotech, SoftSolve, Software India, TCS, Vertex, Vimukti Technologies,
What is the difference between int and float?
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
Define Spanning-Tree Protocol (STP)
What is the difference between typedef and #define?
What are variables c?
What is cohesion and coupling in c?
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.