in Programming in C retagged by
6,380 views
2 votes
2 votes

Following is C like Pseudo code of a function that takes a number as an argument, and uses a stack S to do processing. 

void fun(int n) 
{ 
Stack S;//Say it creates an empty stack S 
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(!is Empty(&S))
printf("%d",pop(&S));//pop an element from S and print it 
} 

What does the above function do in general ?

  1. Prints binary representation of $n$ in reverse order.
  2. Prints binary representation of $n$.
  3. Prints the value of $\log n$.
  4. Prints the value of $\log n$ in reverse order.
in Programming in C retagged by
by
6.4k views

1 comment

option B is correct
1
1

2 Answers

1 vote
1 vote
B) Print binary representaion of n
0 votes
0 votes
it will print Binary Representation of  nā€¦..

option B is correct
Answer:

Related questions