How the ans to first question is 1 if we take n=6
ans is 0 .So i think ans is second option
Q1. Recursion output 1
What does the following function do?
int fun(unsigned int n)
{
if (n == 0 || n == 1)
return n;
if (n%3 != 0)
return 0;
return fun(n/3);
}
options are
It returns 1 when n is a multiple of 3, otherwise returns 0.
It returns 1 when n is a power of 3, otherwise returns 0.
It returns 0 when n is a multiple of 3, otherwise returns 1.
It returns 0 when n is a power of 3, otherwise returns 1.