237. Find the output of the program?... .....
Microsoft Interview Questions and Answers
(Continued from previous question...)
237. Find the output of the program?... .....
Question:
int main()
{
int i = 32242;
int k = find(i);
return k;
}
int find (int j)
{
if (j > 0)
{
j = j%10 + find(j/10);
printf(" %d ", j);
}
return j;
}
Find the output of the program?
maybe an answer:
It prints 3 5 7 11 13.
i.e.from the left it prints
the sum of 1 digit, 3
the sum of 2 digits, 3+2=5
the sum of 3 digits, 5+2=7
the sum of 4 digits, 7+4=11
the sum of 5 digits, 11+2=13
(Continued on next question...)
Other Interview Questions
|