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 _______ is used to analyze and summarize your data without graphical support.
hodyreva [135]
Pivot table is the answer
8 0
3 years ago
Signals can be transmitted in one of two ways. list and explain both
S_A_V [24]
I'm owning a give you one review trouble into the brave explain how you didn't war in the air might help you do the answer so you could go and do that
3 0
4 years ago
Sample answers of What assets were targeted Stuxnet and the team behind the worm?
Damm [24]
The assets were programmable logic controllers (PLCs).  Which controlled systems like prison doors and centrifuges for separating nuclear material. 

The "who" is still debated.  Credit (if you use that word) is given to the Equation Group.  But that is still hotly debated as there seems to be a political agenda with the attack and many still believe this was nation-state sponsored.  I can be easy to leave digital fingerprints behind to make it seem like a known hacking team.
8 0
4 years ago
Give two examples of html presentation
svp [43]

Answer:

Size, colors, borders, margins, etc. can be taken as the example of HTML presentation.

5 0
3 years ago
An administrator needs to set up an authentication server for users connecting to a network through a VPN. What kind of server c
Leya [2.2K]

Answer:

RADIUS

Explanation:

The administrator needs to set up a RADIUS server for this particular example, RADIUS is a networking protocol, this protocol provides centralized Authentication, Authorization for users who connect and use a network service, this is an authentication remote service, and we can use it with the VPN  (virtual private networks).

7 0
3 years ago
Other questions:
  • There was a thunderstorm in your area and the power went out.
    12·1 answer
  • For any element in keysList with a value smaller than 40, print the corresponding value in itemsList, followed by a space.
    6·1 answer
  • Which do switches create?<br> Networks<br> Wireless access points<br> Routes<br> Collision domains
    5·1 answer
  • Electronic business includes which of the following
    5·2 answers
  • Agile methods comprise of 45 subprocesses which are organized into eight process groups.
    10·1 answer
  • Why stress testing is needed?​
    14·2 answers
  • Copyright ownership analysis starts with this principle: The ________ is the owner.
    6·1 answer
  • 50 POINTS
    6·1 answer
  • Why the computer is known as versatile and diligent device ? explain.<br>​
    15·1 answer
  • FCAPS is a network management functional model. FCAPS is an acronym that represents the focal tasks necessary to effectively man
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!