void fun(int n) { Stack S; // Creates an empty stack while (n > 0) { // This…

void fun(int n)

{

Stack S; // Creates an empty stack

while (n > 0)

{
// This line pushes the value of n%2 to stack S
push(&S, n % 2);

n = n / 2;

}
// Run while Stack S is not empty
while (!isEmpty(&S))

printf("%d ", pop(&S)); // pop an element from S and print it

}

  1. A.

    Prints binary representation of n in reverse order

  2. B.

    Prints binary representation of n

  3. C.

    Prints the value of Logn

  4. D.

    Prints the value of Logn in reverse order

Attempted by 319 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…