can we initialize all the members of union?
Answers were Sorted based on User's Feedback
Answer / banavathvishnu
union
{
int a;
char ch;
float f;
}tt = {10};
main()
{
printf("%c",tt.ch);
}
In union it is enough to initialise one variable, same
value will reflect the value in remaning members also.
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / vadivelt
Since Union follows the memory sharing concept, it is not
possible to initialise all union varibles at a time.
ie.,
union name
{
int a;
char b;
}c = {10, 'a'};
is not possible.
But it is possible to initialise one value at a time.
ie.,
union name
{
int a;
char b;
}c = {10};
or
union name
{
int a;
char b;
}c = {'a'};
| Is This Answer Correct ? | 0 Yes | 3 No |
how to multiply two number taking input as a string (considering sum and carry )
What is a MAC Address?
What is an array? What the different types of arrays in c?
Write the Program to reverse a string using pointers.
Evaluate the following: int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7); 1) 10 2) 11 3) 1
what are the stoge class in C and tel the scope and life time of it?
how the compiler treats any volatile variable?Explain with example.
What does 4d mean in c?
void main() { char c; while(c=getchar()!='\n') printf("%d",c); } o/p=11 why?
write aprogram for There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.
1 Answers iGate, Shashi, Source Bits, Subex,
how to write a bubble sort program without using temporary variable?
What is nested structure?