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
What is output if month = 11 and day = 14?
goldfiish [28.3K]

Cheese

…………………………..tggggggcfcgvgvv

4 0
3 years ago
Read 2 more answers
What may happen if a larger number of computer users are attempting to access a Web site at the same time that u r??? I think it
Semmy [17]
I think if a large number are accessing at the same time you would have to wait for many to clear up

3 0
3 years ago
Which network protocol is used to route ip addresses?.
IgorLugansk [536]

Answer:

the Internet Protocol (IP)

3 0
2 years ago
Briefly describe the client/server model.
Lesechka [4]
<span>a distributed application structure that partitions tasks or workloads between the providers of a resource or service, called servers, and service requester, called clients</span>
6 0
4 years ago
What contains programming statement written in VB?​
Alla [95]

Answer:

A statement in Visual Basic is a complete instruction. It can contain keywords, operators, variables, constants, and expressions. Each statement belongs to one of the following three categories: Declaration statements, which name a variable, constant, or procedure and can also specify a data type.

6 0
3 years ago
Other questions:
  • How are information systems used at the industry level to achieve strategic advantage? By enforcing standards that reduce the di
    8·1 answer
  • Create a class CitiesAndCountries with at least three methods: class CitiesAndCountries: def add_country(self, country_name): ""
    7·1 answer
  • Which is the largest unit of measurement for computer data?
    14·1 answer
  • Which model emphasizes the risk analysis phase of development
    12·1 answer
  • How do I do these? I dont understand.
    12·1 answer
  • Which are common applications of deep learning in Artificial Intelligence (AI)?
    5·1 answer
  • Mention some of the codes of conduct of Information Technology (IT)​
    11·1 answer
  • Use a while loop to output the even number from 100 to 147? This is python
    10·1 answer
  • A network administrator is importing a list of certificates from an online source, so that employees can use a chain of trust an
    10·1 answer
  • Which device allows users to directly hear data from a computer
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!