which one is better structure or union?(other than the
space occupied )
Answers were Sorted based on User's Feedback
strucure is always better than union.
there are to reasons
1.
union occupies incorrect memory.
e.g.
if the lower memory space data is preceeded by higher one.
Then memory should be alloted is addition of these two, but
the memory will be alloted will be any one out of higher
and lower there is no way to assure what memory would be
occupied.
2.
the data given in union is not necessarily be(maybe/may not
be) extreacted properly.
but in structure correct amount of memory space will be
occupied and extracting element is easy.
| Is This Answer Correct ? | 13 Yes | 2 No |
Answer / nishit jain
There is no question of which one is better. Both are there
for different functionality. Structures find more usage in
day-today programming, while unions are used less often.
There are examples where structure may not solve the purpose
but unions will work without much effort. Example :
packing-unpacking of data can be done using unions easily.
| Is This Answer Correct ? | 7 Yes | 2 No |
1. Write a C program to count the number of occurrence of a specific word in the given strings. (for e.g. Find how many times the word “live” comes in the sentence “Dream as if you’ll live forever, live as if you’ll die today ”)
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
Is that possible to store 32768 in an int data type variable?
write a c programs to do multiplication of two numbers with out using arithmatic operator ??????????
How is = symbol different from == symbol in c programming?
can we define a function in structure?
What is anagram in c?
What is meant by type specifiers?
How can a string be converted to a number?
What is oops c?
Which one would you prefer - a macro or a function?
The program to allow the characters from the input received and send this function to a function check if the characters between letters a to z is a function of y joins as the characters main and output to otherwise return to the original function of the y characters