GATE CS 2019 (Forenoon) — Question 36

Programming in CFunctions, Parameter Passing, Scope Rules, RecursionMCQ2 marks · −2/3 if wrongMedium

Consider the following C function:
c
1void convert (int n) {
2    if (n < 0)
3        printf("%d", n);
4    else {
5        convert (n/2);
6        printf("%d", n % 2);
7    }
8}
9
Which one of the following will happen when the function convert is called with any positive integer \( n \) as argument?
  1. A
    It will print the binary representation of n and terminate.
  2. B
    It will print the binary representation of n in the reverse order and terminate.
  3. C
    It will print the binary representation of n but will not terminate.
  4. D
    It will not print anything and will not terminate.
Practise the full 2019-FN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAFree All-India Mock — every SundayA full GATE CS paper, exactly 180 minutes, ranked across India with your GATE score.
Practise more on Functions, Parameter Passing, Scope Rules, RecursionTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group