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
Coordination in a global information system requires a _____ architecture for data, standardization within departments.
Phantasy [73]

Coordination in a global information system requires a decentralized architecture for data, standardization within departments

6 0
2 years ago
Is part of a computer's hardware that executes each instruction in a program?
zlopas [31]
The CPU, or central processing unit, is the hardware that takes most of the load when running a program. It will perform complex calculations and execute every instruction as the program continues.

The GPU, or graphics procession unit, is the hardware that could also play a major roll in calculating the instructions to execute a program, though this depends on how graphically intensive the program is. For example, games would use a lot more GPU power than say a simple calculator application.
7 0
3 years ago
Q4. Write down the JavaScript statements to perform the following tasks.
goldenfox [79]

Answer:

Explanation:

In Javascript, you can accept an input value by using the prompt() function and saving the input into a variable. In the following lines of code, I have declared the three variables at the beginning and then prompted the user to enter a value for each and saved the values in the correct variables. In Javascript length is a keyword so I used len instead.

let base, height, len;

base = prompt("Enter Base value: ");

height = prompt("Enter Height value: ");

len = prompt("Enter Length value: ");

5 0
2 years ago
What happens when your project is rendered?
jok3333 [9.3K]

Answer:

B

Explanation:

when your rendering video project your computer is processing all the data that goes into creating images you experience video rendering every time you look at your computer the images on your screen has all been rendered to produce the website photo or video you are looking at

4 0
2 years ago
Create a logic array qualifyingIndex with true for any location where the runner is male with a running time less than 8.2. Row
larisa [96]

Rounding Numbers

Say you wanted to round the number 838.274. Depending on which place value you'll round to, the final result will vary. Rounding 838.274:

Rounding to the nearest hundred is 800

Rounding to the nearest ten is 840

Rounding to the nearest one is 838

Rounding to the nearest tenth is 838.3

Rounding to the nearest hundredth is 838.27

5 0
3 years ago
Other questions:
  • Please help?!
    11·2 answers
  • What is an IP address and where I can find the IP address for my computer?
    14·1 answer
  • If we are using an 4-character password that contains only lowercase English alphabetic characters (26 different characters), ho
    15·2 answers
  • 2. From the listing code, please give the block of line numbers for code which are concerned with the following: A) Main functio
    5·1 answer
  • Write an if-else statement for the following: If user_tickets is less than 5, assign 1 to num_tickets. Else, assign user_tickets
    15·1 answer
  • Complete the steps to evaluate the following
    13·2 answers
  • If a client is found _________ the NAP will attempt to make it _______. Group of answer choices A. non-compliant, compliant B. s
    13·2 answers
  • ppose we have a Rectangle class that includes length and width attributes, of type int, both set by the constructor. Define an e
    9·1 answer
  • How do i make a PDF and what is a PDF<br><br> sorry i am dumb
    14·1 answer
  • Bob The Penguin is a real you-tuber, and he plays Mine-craft. Who is his owner?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!