Consider the code fragment written in JAVA below :
Java
void f ( int n)
{ if (n <= 1 ) {
System.out.print(n);
}
else {
f (n/ 2 );
System.out.print(n% 2 );
}
} |
What does f(173) print?
(A)
010110101
(B)
010101101
(C)
10110101
(D)
10101101
Answer: (D)
Explanation:
(173)2 = 10101101 . Here the function will print the binary representation of 173.
Hence Option(D) is the correct answer.
Quiz of this Question
Please comment below if you find anything wrong in the above post