GATE CS 2019 · Question 36 · Programming and Data Structures · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer
Consider the following C function.
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 and terminate
- (B) It will print the binary representation of n in the reverse order and terminate
- (C) It will print the binary representation of n but will not terminate
- (D) It will not print anything and will not terminate
Answer
Answer (D)
Answer from the official GATE CS 2019 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes