What is the output printed by the following program?
#include<stdio.h>
int f(int n, int k)
if (n
return 0;
else if (n % 2)
return f(n/2, 2*k) + k;
else return f(n/2, 2*k) - k
}
int main()
{
printf("%d", f(20, 1));
return 0;
}
Answers
Answered by
0
Answer:
Error, cause please debug the program
3rd line-error
It will go on a loop until 0 as n i don't know that c++ gives an error on division by 0!
Similar questions