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
At the frequency of 2.4 GHz what is the free-space path loss in dB.
chubhunter [2.5K]

Answer:

The FSBL is 100.05 dB

Solution:

As per the question:

Frequency, f = 2.4 GHz = 2.4\times 10^{9}

Now, we know that to calculate FSBL, i.e., Free Space Path Loss in dB, we use:

FSBL(in dB) = 10log_{10}(\frac{4\pifd}{c})^{2}

where

d = 1 km = 1000

c = 3\times 10^{8} m/s

FSBL(in dB) = 20log_{10}\frac{4\pifd}{c} = 20log_{10}(fd) + 20log_{10}(\frac{4\pi}{c})

FSBL(in dB) = 20log_{10}(f) + 20log_{10}(d) + 20log_{10}(\frac{4\pi}{c})

FSBL(in dB) = 20log_{10}(2.4\times 10^{9}) + 20log_{10}(10^{3}) + 20log_{10}(\frac{4\pi}{3\times 10^{8}})

FSBL(in dB) = 20\times 9.3802 + 20\times 3 - 147.55 = 100.05 dB

6 0
3 years ago
What is the output?
Vinvika [58]

Answer:

20

Explanation:

4 0
3 years ago
What is often called a platform, a collection of computer programs that work together to manage hardware and software to ensure
Nady [450]

Answer:

The correct answer to the following question will be "Operating system".

Explanation:

  • An operating system is a machine software that handles hardware of a computer, computing assets and delivers basic services to software programs.
  • It is an intermediary between such users and computer hardware.
  • It also helps you to interact with your machine without learning how to use your language of the computer.

Therefore, it will be the right answer.

7 0
3 years ago
IS ANYONE ELSE JUST GETTING PPL PUTTING LINKS WHEN U ASK A QUESTION???
TiliK225 [7]
UGH IKR, LIKE JUST ANSWER THE FRICKIN QUESTION
4 0
2 years ago
Read 2 more answers
The GaVS resource where students can locate information regarding Canvas, student email, registration and O365 is called the: St
wariber [46]

I Inferred you are referring to the Georgia Virtual School resource program.

<u>Answer:</u>

<u>Guidance Center</u>

<u>Explanation:</u>

Interestingly, the Georgia Virtual School (GaVS) enables students access to Virtual education.

Their resource platform allows students to find information regarding Canvas, student email, registration and Office 365 etc by simply going Guidance Center.

7 0
3 years ago
Other questions:
  • you install teamviewer on your workstation at home so that you can ac ess it when on the road. how can you be assured that unkno
    9·1 answer
  • If you are viewing a webpage with customized or regenerated content, such as updated stock quotes, what type of webpage are you
    14·1 answer
  • What did I do wrong? May you please correct it for me...I was also looking on how to delay when it prints. Like when it prints a
    9·1 answer
  • MICR is an input or output devices
    5·1 answer
  • How do i do a class in java??
    5·1 answer
  • Why would it be hard to find the ideal CO2 level if the light intensity were very low?
    9·1 answer
  • Pls help computer science I will give brainliest
    8·2 answers
  • The excerpt is a sample works-cited list.
    5·2 answers
  • Need help with this, will give brainliest
    15·1 answer
  • Which of the following statements describe the benefits of a career in transportation, distribution, and logistics (TDL)?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!