1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
bagirrra123 [75]
3 years ago
10

Binary is a base-2 number system instead of the decimal (base-10) system we are familiar with. Write a recursive function PrintI

nBinary(int num) that prints the binary representation for a given integer. For example, calling PrintInBinary(5) would print 101. Your function may assume the integer parameter is non-negative. The recursive insight for this problem is to realize you can identify the least significant binary digit by using the modulus operator with value 2. For example, given the integer 35, mod by 2 tells you that the last binary digit must be 1 (i.e. this number is odd), and division by 2 gives you the remaining portion of the integer (17). What 's the right way to handle the remaining portion
Computers and Technology
1 answer:
Paladinen [302]3 years ago
7 0

Answer:

In C++:

int PrintInBinary(int num){

if (num == 0)  

 return 0;  

else

 return (num % 2 + 10 * PrintInBinary(num / 2));

}

Explanation:

This defines the PrintInBinary function

int PrintInBinary(int num){

This returns 0 is num is 0 or num has been reduced to 0

<em> if (num == 0)  </em>

<em>  return 0;  </em>

If otherwise, see below for further explanation

<em> else </em>

<em>  return (num % 2 + 10 * PrintInBinary(num / 2)); </em>

}

----------------------------------------------------------------------------------------

num % 2 + 10 * PrintInBinary(num / 2)

The above can be split into:

num % 2 and + 10 * PrintInBinary(num / 2)

Assume num is 35.

num % 2 = 1

10 * PrintInBinary(num / 2) => 10 * PrintInBinary(17)

17 will be passed to the function (recursively).

This process will continue until num is 0

You might be interested in
A large retail company hires several new joiners and would like to incorporate Virtual Reality (VR) into their onboarding proces
Volgvan

 The best utilize VR for this purpose is a simulated experience interacting with customers.

<h3>What is Virtual reality (VR)?</h3>

Virtual Reality (VR) is known to be a kind of computer created environment that is made up of scenes and objects that seems to be real.

It is a type of reality that makes its  user feel they are inside their surroundings. This environment is said to be seen via device known as a Virtual Reality headset or helmet.

See options below

Which approach would best utilize VR for this purpose?

an animated video that covers compliance training

a 360-degree online tour of the retail store

an application that enables online contract signing

a simulated experience interacting with customers

Learn more about Virtual Reality (VR) from

brainly.com/question/26705841

4 0
2 years ago
Viết chương trình hoàn chỉnh các yêu cầu sau:
Blababa [14]

Explanation:

the perimeter of an aluminium sheet is 120 CM if its length is reduced by 10% and its breadth is increased by 20% the perimeter does not change find the measure of the length and the breadth of the sheet

4 0
3 years ago
Which of these statements most accurately describes cookies?
horsena [70]
A cookie(s), on a website, is a small text file that is placed on a computer by a website. Most websites online use cookies to track data. A person can turn off their cookie tracking by going into the settings and turning it off. You can directly choose to not have cookies placed on your computer or phone. However, some website does require the cookies to be enabled before you can visit the website. The correct answer will be C. 
5 0
3 years ago
Electronic ledger that tracks mathematical data
lesya692 [45]
<span>These kinds of systems are usually installed in the cockpits of aircrafts. It is an electronic computer-controlled display system. It is made up of several kinds of systems constituting the whole.  The purpose of such a kind of display is to increase and widen the field of vision and decrease any kind of visual disturbances from the surroundings. The Flight Data Display another constituent of the system constantly updates the pilots with the status of and data related to the flight. This also includes information about the aircraft itself and navigation information too.</span>
7 0
3 years ago
To create a formula in______, you would first click in one of the cells​
Pavlova-9 [17]

Answer:excel

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • I need help to find out what is wrong with this program and my variable, "exponent" comes out as 0 in the output instead of the
    14·1 answer
  • To specify grouping and sorting for a report, click the ____ button on the design tab in layout view.
    14·1 answer
  • Which of the following are types of home internet service? Check all that apply
    7·1 answer
  • What is looping in QBASIC​
    9·1 answer
  • When an Ethernet NIC has been configured by the OS to use half-duplex, the transmit pair of the twisted-pair cable usestransmiss
    14·1 answer
  • What are the two ways that assets are
    5·1 answer
  • Which of the following aspects of a computer is responsible for making sense of input? processing output memory storage
    14·2 answers
  • 9. "मेरे तो गिरधर गोपाल, दूसरो ना कोई
    5·1 answer
  • the ghost adventures team uses a variety of tools and technology in investigations. which one is described as an adjustable freq
    9·1 answer
  • The following code appears in a sort function. Will this function sort in increasing order (smallest first) or decreasing order
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!