union
{
char ch[10];
short s;
}test;
test.s = 0xabcd;


main()
{
printf("%d",ch[10]);
}

Answers were Sorted based on User's Feedback



union { char ch[10]; short s; }test; test.s = 0xabcd; main() { printf("%d",..

Answer / shrikant auti

The code written is incorrect......
union
{
char ch[10];
short s;
}test;
test.s = 0xabcd;


main()
{
printf("%d",ch[10]);/*%D CAN'T BE USED FOR CHARACTER
EXTRACTION*/
}

Is This Answer Correct ?    3 Yes 1 No

union { char ch[10]; short s; }test; test.s = 0xabcd; main() { printf("%d",..

Answer / vipul

the program is incorrect bcz in main function %d is used for integer type value and union is same as the structure and there is no return type in the main function thus it will return a charter type value,

Is This Answer Correct ?    0 Yes 0 No

union { char ch[10]; short s; }test; test.s = 0xabcd; main() { printf("%d",..

Answer / maruthi

Answer:it will print the value of test.s because union
allocates memory for the largest sized variable.And 'll get
the value of recently stored variable.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

How can I write functions that take a variable number of arguments?

0 Answers  


What is c language used for?

0 Answers  


Explain the meaning of keyword 'extern' in a function declaration.

0 Answers  


Is the C language is the portable language...If yes...Then Why...and if not then what is problem so it is not a Portable language..???

2 Answers   TCS,


Why can’t constant values be used to define an array’s initial size?

0 Answers  






Are the variables argc and argv are local to main?

0 Answers   TISL,


Is c an object oriented programming language?

1 Answers  


write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34

0 Answers  


If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.

0 Answers   TCS,


What is static identifier?

0 Answers   TCS,


Result of the following program is main() { int i=0; for(i=0;i<20;i++) { switch(i) case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break;} printf("%d,",i); } } a)0,5,9,13,17 b)5,9,13,17 c)12,17,22 d)16,21 e)syntax error

8 Answers   IBM,


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

0 Answers   Aegis, CDAC, Infosys,


Categories