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]
4 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]4 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
Rey is recording the dialogues and sound effects separately in the studio, as he is not happy with the sound quality recorded on
Harlamova29_29 [7]

Answer:

Option C, Recording

Explanation:

In  music mixing different tracks are optimized and mixed into a mono track. It does not involve recording and hence option B is incorrect

Synchronization is a process of using music after taking permission into visuals and pictures. Thus, option A is also incorrect

Editing is simply music editing, no recording hence option D is also incorrect.

Thus, option C is correct

6 0
3 years ago
A researcher wants to do a web-based survey of college students to collect information about their sexual behavior and drug use.
Kay [80]

Answer:

magnitude and the probability of it occurring

Explanation:

In every single study that involves an individuals risk of self-harm there are two variables that need to be evaluated, and those are the magnitude and the probability of it occurring. In other words how likely is the individual to hurt themselves and if they do, to what extent (physical, emotional, death). By evaluating this can allow you to take action if things get to serious, or even prevent something from happening that can lead that person that is at risk from hurting themselves.

4 0
4 years ago
What is the Keyboard shortcut to change the case of selected text?
kogti [31]

Answer:

Select the text and then press Shift + F3 until the case you want is applied.

5 0
3 years ago
You are creating a business report for your organization. Where will you find the options to edit the margins of your document?
prisoha [69]

Headers and footers

3 0
4 years ago
Read 2 more answers
PLEASE ANSWER THIS ASAP‼️
Reil [10]

c) the grasses

plants are producers

4 0
3 years ago
Read 2 more answers
Other questions:
  • Tanya is entering the amount of money she has earned from babysitting onto an Excel spreadsheet, but the AutoComplete feature is
    9·2 answers
  • Operating systems such as Microsoft Windows use a specific character before a file extension to separate it from the filename. W
    9·2 answers
  • The manufacturer doesn't need it the buyer doesn't want it the user doesn't know they're using it
    6·1 answer
  • Which one of the following may be used as an input as well as an output device? A. Fax machine B. Scanner C. Printer D. Voice re
    9·1 answer
  • Write a Python function called simulate_observations. It should take no arguments, and it should return an array of 7 numbers. E
    7·1 answer
  • Modify the NumberedList class we implementd during the lecture by adding a member function: void NumberedList::insertPosition(in
    13·1 answer
  • Tips for Interactions with Personalized LinkedIn Outreach?
    5·1 answer
  • Using social media, such as text messages and status updates, has helped
    10·1 answer
  • A. Fill in the blanks:
    6·1 answer
  • Any idea how to make my simple python projects such as guess the number, mad libs, etc. even better?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!