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
Without entering into the internet cloud or intranet cloud, how many icons in the topology represent endpoint devices (only one
KengaRu [80]

I guess the correct answer to your question is 15.

6 0
3 years ago
If you wanted to divide an integer variable by 2, which of the following lines of code would you use? total = int + 2 total = in
Lesechka [4]

Answer:

Yes

Explanation:

Because all answers are intotal (2)

8 0
3 years ago
You are the IT Administrator for a small corporate network. Until now, the network has consisted only of workstations accessing
ser-zykov [4K]

Answer:

Explanation:

Since you are using Windows Server 2012 these tasks are much easier. In order to accomplish this, you simply need to click on Disk Management in the GUI and then right-click on the 200 GB drive and click on the option that says "Extend Drive". Finally, choose the max available space for the drive and click accept. This will extend the drive completely to use all of the space. The same process can be done for changing the Drive Letter and Volume Label by right-clicking the drive and choosing the corresponding option. In order to get convert the file system to NTFS (assuming it is Fat32) you simply need to open command prompt and type the following command.

convert m:  /fs:ntfs

where m is the actual drive letter of the drive in question.

8 0
3 years ago
ASAP BRAINLIEST!!!
Hoochie [10]

Answer:

none

Explanation:

6 0
3 years ago
Under what circumstances are composite primary keys appropriate?
guajiro [1.7K]
A composite primary key<span> is a set of several primary </span>keys<span> that, together, uniquely identifies each record.</span>
Primary keys are used as identifiers of composite entities. In this case each primary key combination is allowed only once in the *:* relationship.
Other case where primary keys are used is as identifiers of weak entities, where the weak entity has a strong identifying relationship with the parent entity. 
8 0
4 years ago
Other questions:
  • Which of the following characters at the beginning of a cell signifies to Excel that it should perform a calculation for the val
    13·1 answer
  • How does microchip work
    12·1 answer
  • If you want to write some fancy interface on your computer with expanded communication to the Arduino, what library should you u
    13·1 answer
  • Moderate changes to existing processes falls under the _________ analysis. Business Process Automation (BPA) Business Process Im
    5·1 answer
  • What is Quantum Cryptography? How is it different from Public and Private-key transactions?
    6·1 answer
  • Write a program that asks you to enter some integers, and press "enter" after each one.
    13·1 answer
  • Describe any five GSM PLMN basic services?
    10·1 answer
  • Develop a stored procedure that will take a state abbreviation as a parameter and list the name of the state, vendor, and total
    9·1 answer
  • Mention and discuss specific professional ethics related to augmented reality, artificial intelligence, and the internet of thin
    6·1 answer
  • When you try to move the desktop icon using the click and drag method and it doesn't move, what is the reason?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!