Consider the following C function. void convert(int n){ if(n<0)…

GATE · 2019 · CS · Computer Science & IT

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?

  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

Attempted by 358 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…