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
Complete the sentence. <br><br> ____ Is the study and use of very small technology units
kondor19780726 [428]

Answer:

nanotechnology

Explanation:

I just took the test

3 0
4 years ago
The Circular Flow Model includes serveral actors. Which of the following is NOT listed in the Circular Flow Model?
Ierofanga [76]
I believe it would be Charities

4 0
3 years ago
What subsection of the Internet requires specialized browser to access and is frequently used by cyber criminals and underground
kotykmax [81]

Answer:

c. Dark Web                                                

Explanation:

Surface web is also called visible web is a part of world wide web that can be easily searchable using search engines as its contents are indexed by the search engines such as Google and its contents are accessible by public using standard web browsers. So a is not a suitable choice.

Deep Web is called invisible web as it is not accessible or searchable to standard search engines like Google. Search engines cannot index the contents of these sites. However such sites do not requires specialized browsers to access. So b is not a suitable choice.

Dark Web: It is a part of Deep Web sites but it requires specialized software and browsers to access. These sites cannot be indexed and cannot be searchable through standard search engines. This is also called dark side of the world wide web darker which is frequently used by criminals, hackers, black markets, hit-men. Illegal activities on a massive level is takes place in the dark web such as access to stolen sensitive information, malware, drug trade and terrorist operations. These sites are temporary and keep changing addresses to lessen the risk of getting caught by govt agencies or security officials. So c is the suitable choice.

Crypto-Net is a kind of neural network which works with encrypted data which can make a prediction based on the data without disclosing the data and prediction to the 3rd party. So d is not a suitable option.

6 0
3 years ago
Write 4 types of network_based<br>on geographical area covered<br>by them​
ikadub [295]

Answer:

Network based coverages are LAN, WAN, MAN and WLAN

4 0
3 years ago
What is the average time a caller waits for an operator to answer?
kaheart [24]
3-4 minutes is about right is say
7 0
4 years ago
Other questions:
  • What is the value of the variable result after these lines of code are executed?
    5·2 answers
  • In which section of a document would you include image acknowledgments for the images used ?
    8·2 answers
  • What is a pin? part of a connector a port part of a cable a NIC
    14·1 answer
  • Which of the following files has the Ionic styles? ionic.bundle.css ionic.js ionic.css ionic.bundle.js
    13·1 answer
  • WHY IS BRAINLY NOTIFICATIONS LIKE THIS?????
    15·2 answers
  • It is common for people to name directories as dir1, dir2, and so on. When there are ten or more directories, the operating syst
    8·1 answer
  • Which element is represented by the electron configuration in example B? Example B: 1s22s22p63s23p64s1 Aluminum Cesium Potassium
    12·2 answers
  • Which of the following components converts AC to DC?
    5·1 answer
  • The main difference between \f and \r is that \f produces a
    13·1 answer
  • What are two best practices for creating ads? (Choose two.) Select All Correct Responses Implement one ad per ad group per keywo
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!