Computer Sciences > Gate 2019 > Recursion
Consider the following C program:

void convert(int n) {
    if (n < 0)
    printf(“ % d”, n);
    else {
      convert(n / 2);
      printf(“ % d”, n % 2);
}
}
Which one of the following will happen when the function convert is called with any positive integer n as argument?
A
It will print the binary representation of n in the reverse order and terminate.
B
It will print the binary representation of n but will not terminate.
C
It will not print anything and will not terminate.
D
It will print the binary representation of n and terminate.

Correct : c

Similar Questions

Consider the following C function. int fun (int n) { &nbsp; &nbsp; int x=1, k; &nbsp; &nbsp; if (n==1) return x; &nbsp; &nbsp; for (k=1; k < n; ++k) &...
#527 Fill in the Blanks
Consider the following C function. int fun (int n) { &nbsp; &nbsp; int x=1, k; &nbsp; &nbsp; if (n==1) return x; &nbsp; &nbsp; for (k=1; k < n; ++k) &...
#527 Fill in the Blanks
Consider the following C function. int fun (int n) { &nbsp; &nbsp; int x=1, k; &nbsp; &nbsp; if (n==1) return x; &nbsp; &nbsp; for (k=1; k < n; ++k) &...
#527 Fill in the Blanks

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......