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
ANSWER ASAP!!! 12 POINTS!!!!! RIGHT ANSWERS ONLY
suter [353]

Answer:

B.

Explanation:

8 0
2 years ago
Read 2 more answers
One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input
salantis [7]

Answer:

import java.util.Scanner;

public class Miles {

public static void main(String[] args) {

   //initialization

       double Number_Miles;

       //print the message

       System.out.print("Enter the number of miles: ");

       Scanner scn1 = new Scanner(System.in);

       

       Number_Miles = scn1.nextDouble();  //read the input from user

       //calculate the laps

       double yourValue = Number_Miles/0.25;

       //display the output on the screen

       System.out.printf("%.2f", yourValue);

     

}

}  

Explanation:

First import the library Scanner than create the class and define the main function. In the main function, declare the variables.

print the message on the screen and then store the value enter by the user into the variable.

Scanner is a class that is used for reading the output. So, we make the object of the class Scanner and then object call the function nextDouble() which reads the input and store in the variable.

After that, calculate the number of laps by dividing the number of miles with the given one lap running track value (0.25 miles).

Number\,of\,laps = \frac{Number\,of\,miles}{0.25}

the output is stored in the variable.

After that, print the value on the screen with 2 digits after the decimal point.

we can use "%.2f" in the printing function in java.

like System.out.printf("%.2f", output);

5 0
3 years ago
Read 2 more answers
A menu within a menu is called what?​
Aneli [31]

Answer:

a submenu

Explanation:

a menu inside a menu is called a submenu or recursive menu

4 0
3 years ago
45. Our goals are a reflection of our:
ZanzabumX [31]
Values hope it helps you
4 0
2 years ago
What are the business drivers of cloud computing?(Choose all that apply.)
Xelga [282]

Answer:  The applicable answers are b, c, and d.

Explanation:

When a company decides to hire the services of a cloud computing service provider, instead of investing in purchasing the resources needed in order to match its needs, as the cloud model is based on the concept "pay as you go", it allows to maximize the costs efficiency, and at the same time, gives the company the choice to define what type of steps are needed to grow, and when it is advisable to go beyond.

Finally, as it is possible to expand the services hired on the fly very easily, it is a very good way to be sure that it will never ran out of resources, no matter that future needs could be.

Actually, the only answer that is wrong is a) because it happens just the opposite: Cloud services allow to decrease time to market substantially.

7 0
3 years ago
Other questions:
  • kai is interviewing for a job, and the interviewer asks him for an example of skill at cooperating with others. Which example be
    14·2 answers
  • o maintain reasonable key security (mark all that apply): Ensure that someone else always has an extra key. Ensure that no extra
    10·1 answer
  • A is a paid placement that appears in a search engines results page at or near the top of the results
    5·1 answer
  • Arrange the steps below to outline what maia needs to do to accomplish this task.​
    9·1 answer
  • Which rotation speed is not a typical spindle rotation speed for magnetic hard drives?3100; 5400; 7200; 10000
    8·1 answer
  • Which graphics format works best for desktop publishing and print work? (1 point) .tiff .gif .tga .jpeg?
    11·1 answer
  • True or false? Resistors regulate and limit electrical current. A. True B. False
    7·2 answers
  • Besides a backup technician, who else would have encrypted backup passwords?
    7·1 answer
  • Does anyone know 7.1.3: Firework karel?
    5·1 answer
  • PYTHON HW PLEASE HELP. I NEED THE ACTUAL CODE!!! 100 POINTS AND BRAINLIEST. REPORTING IF YOU DON'T ANSWER
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!