Question: What does the following code fragment print when N = 43? Stack stack = new Stack(); while (N > 0) { stack.push(N % 2); N
What does the following code fragment print when N = 43?
Stack stack = new Stack();
while (N > 0) {
stack.push(N % 2);
N = N/2; }
for (int d : stack) StdOut.print(d);
StdOut.println();
1. 101010
2. 001011
3. 101000
4. 101111
5. 101011
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
