What will be printed as the result of the operation below ??
C Interview Questions and Answers
(Continued from previous question...)
What will be printed as the result of the operation below ??
#define swap(a,b) a=a+b;b=a-b;a=a-b;
void main()
{
int x=5, y=10;
swap (x,y);
printf(“%d %d\n”,x,y) ;
swap2(x,y);
printf(“%d %d\n”,x,y) ;
}
int swap2(int a, int b)
{
int temp;
temp=a;
b=a;
a=temp;
return 0;
}
as x = 5 = 0×0000,0101; so x << 2 -< 0×0001,0100 = 20; x >7gt; 2 -> 0×0000,0001 = 1. Therefore, the answer is 5, 20 , 1
the correct answer is
10, 5
5, 10
Answer: 10, 5
(Continued on next question...)
Other Interview Questions
|