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
Is the following statement true or false information literacy is a subset of health literacy
BARSIC [14]

the answer is false because information literacy is a whole other type. you don't need it for the structure of health literacy.                              

4 0
3 years ago
When light hits an opaque object it will be _______________.
nikklg [1K]
None of it passes through. Most of the light is either reflected by the object or absorbed and converted to heat. Materials such as wood, stone, and metals are opaque to visible light.

Good luck
7 0
2 years ago
Anchor hyperlink to position the cursor to the section called sisters? i need a code pls
enot [183]

use an anchor tag(<a>This is an anchor tag</a>) and use the href attribute and set it's destination to the section element who's id or class is "sisters".



Example:

<a href="#Sisters">Click Here!</a>

then you can add this somewhere on the document.

<section id="Sisters">Hello World!</section>

7 0
3 years ago
What is the importance of the international employment​
My name is Ann [436]

Answer:

People who went overseas to work can learn different skills and technologies which can be beneficial for the development of our own country.

7 0
3 years ago
Read 2 more answers
Which type of cause and effect organizer would be best for alisha to understand how crude oil becomes gasoline?
sukhopar [10]
The answer is 100% B. Flow chart.
5 0
3 years ago
Read 2 more answers
Other questions:
  • What part of the communication feedback loop results in unclear communication?
    13·1 answer
  • Some hardware can be added to the computer without having to restart or power down the computer. After a short period of time th
    5·1 answer
  • How is a correction made to an Electronic health record?
    14·1 answer
  • Enterprise Resource Planning (ERP) is an example of a single user database.
    7·1 answer
  • The area of a square is stored in a double variable named area. write an expression whose value is length of the diagonal of the
    8·1 answer
  • What type of Internet monitoring technique records information about a customer during a web surfing session, such as what websi
    8·1 answer
  • 7.) Title text boxes on every slide must be the same format. <br> A. True <br> B. False
    15·2 answers
  • Which of the following behaviors does not harm a company if your employment is terminated?
    9·1 answer
  • Which of the following statements about wide area networks are true? Select 3 options.
    11·1 answer
  • .WAP to enter monthly sale of Salesman and give him commission i.E. If the monthly sale is more than 500000 then commision will
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!