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
"what should you do if the system continually reboots and you can't read the error message produced on a blue screen
mr_godi [17]
I am fairly sure the command for boot options is F11, and if not, then power down the system manually and turn it back on
4 0
3 years ago
Read 2 more answers
Design and implement an application that reads a string from the user then determines and prints how many of eachlowercase vowel
frez [133]
Design and implement an application that reads a string from the user, then determines and prints how many of each lowercase vowel (a, e, i, o, and u) appear in the entire string . Have a separate counter for each vowel. Also count and print the number of nonvowel characters .

SPECIFICATION OF PROMPTS, LABELS AND OUTPUT : Your code should use the prompt "enter string : ". After the input is read, there are six lines of output , each starting with a different label: "a: ", "e: ", "i: ", "o: ", "u: ", "other: " in that order. After each label is the required count.

For example: if "aardvark heebie jeebies" were read in,
4 0
2 years ago
An additional factor in how an element is rendered is that properties are passed from a parent element to its children in a proc
belka [17]

Answer:

style inheritance

Explanation:

What happens when a property on an element has no value supplied is governed by style inheritance. A property should inherit its value from its parent element, according to this specification.

6 0
2 years ago
How does a firewall provide network security
ehidna [41]
Firewalls are connected with a network device which blocks untrusted network forming a barrier in between trusted and un-trusted network.
8 0
3 years ago
The main circuit board of a computer is the _______. The ______ is located on the circuit board. The _____ is the circuitry that
Inessa05 [86]

Answer:

The main circuit board of a computer is the Motherboard. The Processor(CPU) is located on the circuit board. The Processor(CPU) is the circuitry that processes information. The CPU is also known as the brain of the computer. The speed of the processor is controlled by the clock. The system clock controls the timing of all computer operations.

Explanation:

4 0
3 years ago
Other questions:
  • Why is there more content on youtube in 4k then there is on cable, satellite, and digital tv combined?
    6·2 answers
  • Define a function CoordTransform() that transforms its first two input parameters xVal and yVal into two output parameters xValN
    7·2 answers
  • Help me with this, please. Are vacuum cleaners, Cd players, and telephones considered computers? Do they store any data or proce
    8·2 answers
  • Write the definition of a function reverse, whose first parameter is an array of integers and whose second parameter is the numb
    15·1 answer
  • Does white space have visual weight? Yes or No
    7·2 answers
  • A group consists of 10 kids and 2 adults. On a hike, they must form a line with an adult at the front and an adult at the back.
    10·1 answer
  • 20 points for ez question lol
    9·2 answers
  • I’ll mark brainlest
    14·2 answers
  • What is the difference between EPROM and EEPROM, explain why​
    11·1 answer
  • Which of the following could be a method for an object-oriented class called Student?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!