What will be the output of following code for n=7 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What will be the output of following code for n=7

int f(int n) { if(n==0) return 0; else return f(n/2)*10+n%2; }

18th Dec 2019, 4:53 AM
Naman Pandey
Naman Pandey - avatar
2 Answers
0
This code will not give you any results because it is poorly written.
19th Dec 2019, 1:01 AM
Kacper Bąk
Kacper Bąk - avatar
0
The question is not wrong.It is a Recursive method
19th Dec 2019, 3:44 AM
Naman Pandey
Naman Pandey - avatar