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
True [87]
3 years ago
11

Write a function decimalToBinaryRecursive that converts a decimal value to binary using recursion. This function takes a single

parameter, a non-negative integer, and returns a string corresponding to the binary representation of the given value. The function name: decimalToBinaryRecursive The function parameter: An integer to be converted to binary Your function should return the binary representation of the given value as a string Your function should not print anything Your function should use recursion. Loops are not allowed.

Computers and Technology
1 answer:
Delicious77 [7]3 years ago
5 0

Answer:

Check the explanation

Explanation:

#include <iostream>

#include <string>

using namespace std;

string decimalToBinaryRecursive(int n) {

   if(n == 0) {

       return "0";

   } else if(n == 1) {

       return "1";

   } else {

       int d = n % 2;

       string s;

       if (d == 0) {

           s = "0";

       } else {

           s = "1";

       }

       return decimalToBinaryRecursive(n/2) + s;

   }

}

int main() {

   cout << decimalToBinaryRecursive(0) << endl;

   cout << decimalToBinaryRecursive(1) << endl;

   cout << decimalToBinaryRecursive(8) << endl;

   return 0;

}

See the output image below

You might be interested in
2. Identify the diagram and define it.<br>13. What are pollen grains ?<br>4. What is an embryo?​
Virty [35]

Answer:

2. I can't help you with this question because i can't see the diagram

13.Pollen grains are microscopic bodies that have the male reproductive cell of the plant.

4. An Embryo is an organism in its early stage of development.

Explanation:

2. I can't help you with this question because i can't see the diagram

13.Pollen grains are microscopic bodies that have the male reproductive cell of the plant.

4. An Embryo is an organism in its early stage of development.

7 0
3 years ago
Name the part of the computer that stores all information and software.
Paladinen [302]

Answer:

Hard Drive

Explanation:

8 0
3 years ago
Read 2 more answers
Measurement consists of:__________
Naddik [55]

Answer:

The answer is choice "a".

Explanation:

Measurement is a number allocation in which the entity or event attributes that would be comparable with other objects or events. Its scope and implementation depending on context and discipline.  

  • Its main purposes could be defined as measurements for efficiency, tracking, health, fitness (design, mounting), and solving problems.  
  • Its calculation consists of the numerical assignment, representing attribute amounts according to the rules for objects and events.
3 0
3 years ago
The contents of an array of type ______ can be displayed with the cout operator (without specifying an element). - 1 point(s)
xxMikexx [17]
The contents of an array of type char can be displayed with the cout operator.  <span>Array declarations </span>must<span> contain the information about the size of the array. It is possible to leave the size out of the [ ] in the declaration </span>as long as<span> you initialize the array inline, in which case the array is made just large enough to capture the initialized data. </span>  
5 0
3 years ago
What is after Windows 8.1
MAVERICK [17]

Windows 10. The most well-known Windows operating systems are Windows 7, 8, and 10.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following accurately completes this sentence? The Internet is ____.
    6·2 answers
  • Technlogies are having a negative impact on business true or false
    7·1 answer
  • What can be done to improve the security of business uses of the Internet? Give several examples of ecurity measures and technol
    9·1 answer
  • What technology will examine the current state of a network device before allowing it can to connect to the network and force an
    7·1 answer
  • Can somebody tell me when is ps5 releasing???​
    15·2 answers
  • You accidentally moved your task bar from the bottom of the screen to the left side. You would like to
    14·2 answers
  • The marketplace is the essence of which of the following?
    11·1 answer
  • Which kind of testing runs the system in a simulated environment using simulated data?a) validation testing. b) verification tes
    5·1 answer
  • Assume myString and yourString are variables of type String already declared and initialized. Write ONE line of code that sets y
    15·1 answer
  • In the scenario below, decide whether you should upgrade the computer or replace it. You’ve been working on your existing laptop
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!