whats dos this C program do and what will happen when plug t

whats dos this C program do and what will happen when plug the numbers below into it.

What does the following recursive function do? I want the overall function, not what each line of code does. int prog (int n) {int ans; if(n-1) ans = 0; else ans = 1 + prog (n/2); return (ans);}

Solution

This program takes a number from user as input and divide that number recursively by 2 till we get quotient by 1.

As we get quotient =1 i.e n=1 it assign value of ans to 0 and then return that value.

whats dos this C program do and what will happen when plug the numbers below into it. What does the following recursive function do? I want the overall function

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site