subject

Consider the following recursive method, which is intended to display the binary equivalent of a decimal number. For example, toBinary(100) should display 1100100. public static void toBinary(int num)
{
if (num < 2)
{
System. out. print(num);
}
else
{
/* missing code */
}
}

Which of the following can replace /* missing code */ so that toBinary works as intended?

a. System. out. print(num % 2);
toBinary(num / 2);

b. System. out. print(num / 2);
toBinary(num % 2);

c. toBinary(num % 2);
System. out. print(num / 2);

d. toBinary(num / 2);
System. out. print(num % 2);

e. toBinary(num / 2);
System. out. print(num / 2);

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:30
The cm is responsible for overseeing the actions of the crisis management team and coordinating all crisis management efforts in cooperation with disaster recovery and/or business continuity planning, on an as-needed basis
Answers: 1
question
Computers and Technology, 22.06.2019 04:30
Which of the statements below is true? the formatting, standard, and drawing commands are unavailable. the formatting, standard, and drawing commands have been used. the formatting, standard, and drawing toolbars are displayed. the formatting, standard, and drawing toolbars are hidden.
Answers: 1
question
Computers and Technology, 22.06.2019 05:20
Write a program called assignment3 (saved in a file assignment3.java) that computes the greatest common divisor of two given integers. one of the oldest numerical algorithms was described by the greek mathematician, euclid, in 300 b.c. it is a simple but very e↵ective algorithm that computes the greatest common divisor of two given integers. for instance, given integers 24 and 18, the greatest common divisor is 6, because 6 is the largest integer that divides evenly into both 24 and 18. we will denote the greatest common divisor of x and y as gcd(x, y). the algorithm is based on the clever idea that the gcd(x, y) = gcd(x ! y, y) if x > = y and gcd(x, y) = gcd(x, y ! x) if x < y. the algorithm consists of a series of steps (loop iterations) where the “larger” integer is replaced by the di↵erence of the larger and smaller integer. this continues until the two values are equal. that is then the gcd.
Answers: 3
question
Computers and Technology, 22.06.2019 10:30
Aconstruction company is creating a powerpoint presentation describing how they calculate costs during each construction step. they plan to email this presentation to clients. the individual clients will be watching the presentation slide show on their own personal computers. what is the most important formatting step the company should take to make the text readable and pleasing to the eye?
Answers: 2
You know the right answer?
Consider the following recursive method, which is intended to display the binary equivalent of a dec...
Questions
question
Mathematics, 28.09.2020 05:01
question
Mathematics, 28.09.2020 05:01
Questions on the website: 13722359