Find the output of the following code -...
Microsoft Interview Questions and Answers
(Continued from previous question...)
56. Find the output of the following code -...
Question:
Find the output of the following code -
int find(int j)
{
if(j>1)
{
j=find(j/10)-(j%10);
printf("%d",j);
}
else
{
j=0;
}
return j;
}
int main()
{
int i=19222;
int k;
k=find(i);
}
maybe an answer1:
o/p: -9-11-13-15
k = -15
maybe an answer2:
find(1922)-2
find(192)-2-2
find(19)-2-2-2
find(1)-9-2-2-2
=-15
-15-(-2)=-13
-13-(-2)=-11
-11-(-2)=-9
since it has to be in temp buffr b4 printing
order vll be reverse
therefore, -9-11-13-15
(Continued on next question...)
Other Interview Questions
|