Question: Consider the following code fragment: int n, m, b; String s = ; n = kbd.nextInt(); while(n > 1) { m = n / 2;

Consider the following code fragment:

int n, m, b; String s = ""; n = kbd.nextInt(); while(n > 1) { m = n / 2; b = n % 2; s = b + s; n = m; } s = n + s; System.out.println(s);

What is the output if the user enter 9?

options:

110

101

1001

1010

1110

1011

100

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!