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

What is the meaning of && in c?

0 Answers  


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   HCL, iGate,


char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)

7 Answers   Mascot,


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

0 Answers  


could u able to tell about suresoft technical session

1 Answers  






character array A[12] can hold

5 Answers   Wipro,


dibakar & vekatesh..uttejana here..abt ur reply for in place reversal of linked list..wats p stands for there?

1 Answers  


Write a program to swap two numbers without using a temporary variable?

0 Answers   Infosys,


What is getch() function?

0 Answers  


5. What kind of sorting is this: SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort

2 Answers   Accenture,


how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

0 Answers   TCS,


What is page thrashing?

0 Answers  


Categories