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
The rules and guidelines for appropriate computer mediated communication are called?
irinina [24]
<span>The rules and guidelines for appropriate computer mediated communication are called netiquette. 
It is a blend of two words: net (from Internet) and etiquette, or the appropriate behavior. 
</span>
4 0
4 years ago
The best reason for using Independent software test teams is that
Kobotan [32]
The answer is B) A test team will test the software more thoroughly
4 0
3 years ago
Which of the following includes premium content you must pay to use?<br> On word
kotykmax [81]

Some premium contents on Microsoft Word that you must pay before using them include:

  • 1 TB of OneDrive cloud storage
  • Advanced security
  • Expanded technical support
  • Premium templates, among others.

<h3>What are Premium Contents or Features?</h3>

Premium contents or features are exclusive features that have higher quality when compared to the usual quality. In an application like Microsoft Word, there are premium contents or features that can only be used or made available when you subscribe.

Some premium contents on Microsoft Word that you must pay before using them include:

  • 1 TB of OneDrive cloud storage
  • Advanced security
  • Expanded technical support
  • Premium templates, among others.

Learn more about premium contents on:

brainly.com/question/24749457

5 0
2 years ago
What term is used to describe the average amount of time that will pass for a device before a failure is expected to occur?
sleet_krkn [62]
A mean is another word for average (kind of)
7 0
3 years ago
Which sentences or phrases in the passage hint at a bad work habit? Samantha works as an intern at a marketing firm. She always
Verdich [7]
<span>There are two sentences here that hint at a bad work habit.

1.She always shows up for work later than she is expected to but delivers her assignments as per her deadlines.

Here we see that Samantha not only is late to work, but she does it regularly. This is an example of a bad work habit, as being on time is one of the responsibilities of an employee. This also sends a bad massage to her coworkers, if she is not punished for it. That can lead to disorganization and loss of production.

2.She always tries her best to learn new skills even though she does not show up for work regularly.

Again, showing up for work is a must, except your company does not explicitly have a flexible work schedule that allows people to work from home or make their own working hours. In Samantha's case that does not seem to be the case and thus this is a bad habit. </span>
<span />
3 0
3 years ago
Other questions:
  • Which should you use to find a saved file?
    15·2 answers
  • Hiiiiiiiiiii hiiiiiiiiiiiiiiiiiii
    9·2 answers
  • Design a full adder circuit using NAND gates only (input : A, B, Cin and output = S, Cout).
    5·1 answer
  • Write a SELECT statement that returns three columns: EmailAddress, OrderID, and the order total for each customer. To do this, y
    14·1 answer
  • You implement basic version control and go through the phase of creating a local repository. Initiate the commands to set up tha
    7·1 answer
  • Common separators or delimiters used when converting a table to text include _______________________ , paragraph marks, or comma
    14·1 answer
  • Which statement is true about dynamic microphones?
    11·2 answers
  • Question is on the picture thank you
    10·1 answer
  • List out any four hardware and software components required for multimedia​
    10·1 answer
  • What options are available for storing backups, physically?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!