1,050 views
2 votes
2 votes
. What will be the value returned by the following function, when it is called with 11?

recur (int num){

if ((num / 2)! = 0 ) return (recur (num/2) *10+num%2);

else return 1;

}

(a) Function does not return any value, because it goes into an infinite loop (b) 11 (c) 1011 (d) None of these

3 Answers

3 votes
3 votes

This is basically a program to get binary representation of a number. Given N, returns the binary for N

0 votes
0 votes
a is the correct option. because function goes infinite loops, so it does  not return any value.

Related questions

1 votes
1 votes
3 answers
3
jverma asked May 23, 2022
1,090 views
#include <stdio.h>int f(int n){ static int r = 0; if (n <= 0) return 1; r=n; return f(n-1) + r;}int main() { printf("output is %d", f(5)); return 0;}Ou...