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
What type of media is a hard disk​
anyanavicka [17]

Answer:

A hard disk provides a high-capacity alternative to magnetic storage media. It contains metal platters coated with a magnetic layer. The platters usually spin continuously when a computer is on, storing data in different sectors on the magnetic disk.

Explanation:

5 0
3 years ago
There are _______ bits to every byte.
MrMuchimi

8. according to Google, 1 byte = 8 bits

7 0
3 years ago
Read 2 more answers
What are five don’ts of using a computer
Sonja [21]

Answer:

well, as long as there are no right or wrong answers, don't:

look to closely at the screen, as it may mess up your eyes

hold a drink above the computer, as it may spill and cause "sticky keys"

go to sites that you know will give your a computer a virus, cause they cost hundreds of dollars to repair, and some aren't able to come out

go on illegal sites/do illegal operations to the computer itself, because then you won't have a computer

Explanation:

3 0
3 years ago
Read 2 more answers
Características que debe tener un módulo o kit tecnológico para aprender​
12345 [234]

Answer:

Multi herramientas

Explanation:

Un kit tecnologico debe contener todas las herramientas necesarias para el trabajo que lo necesites, por ejemplo destornillador magnetico con varias puntas, herramientas para desmontar y por supuesto tener buena claridad para trabajar y alcohol isoprofilico de al menos 90+ para limpiar electronicos.

5 0
2 years ago
An application team plans to follow the 10-phase SDLC model. After the team identifies both functionality and security requireme
Valentin [98]

Answer:

The team did not adequately formalize the software's design

Explanation:

The most logical reason for this confusion is the fact that the team did not adequately formalize the the software design.

The design approach has to do with clearly defining the architectural modules of the application. The requirements in the software requirement specification document would serve as input for the next phase. The documents are prepared and they give a definition of the overall system architecture.

The team got confused because they did not go through this phase of the 10-phase SDLC model.

3 0
2 years ago
Other questions:
  • When uninstalling software, it is best to delete the folder containing the software?
    11·1 answer
  • Mateo could not find the undo command or shortcut. He should _____.
    15·2 answers
  • Which is an example of Raw Input?
    11·1 answer
  • sparse(compact) Description: A sparse matrix is a 2D matrix that has many zeros. Assume that for storage efficiency someone has
    9·1 answer
  • Why are computers useful for modeling situations?
    13·2 answers
  • What other options are there besides jail for 16 year old that commit a crime?
    8·2 answers
  • Multiple Choice
    8·1 answer
  • How has technology impacted our lives and the world we live in? In your own words.
    9·1 answer
  • Does anyone know what episode Hinata threatens useless sakura?
    9·1 answer
  • When and why would you use a prefab? <br> Subject video gaming
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!