Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


can we initialize all the members of union?

Answers were Sorted based on User's Feedback



can we initialize all the members of union?..

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

can we initialize all the members of union?..

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

Post New Answer

More C Interview Questions

Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.

0 Answers  


while initialization of two dimensional arrays we can initialize like a[][2] but why not a[2][] is there any reason behind this?

4 Answers   Aptech,


Differentiate between #include<...> and #include '...'

0 Answers  


What is the concatenation operator?

0 Answers  


How are Structure passing and returning implemented by the complier?

0 Answers   TISL,


consagous technology placement paper

3 Answers   Consagous, Sypra,


how many header file is in C language ?

44 Answers   College School Exams Tests, CTS, IBM, IMS, Infosys, ME, Sign Solutions, Wipro, XVT,


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

0 Answers  


What is the maximum no. of arguments that can be given in a command line in C.?

0 Answers   HCL,


What is an array? What the different types of arrays in c?

0 Answers  


How would you find a cycle in a linked list?

3 Answers   NSN,


GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

0 Answers  


Categories