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
Briefly explain the following terms and concepts:
morpeh [17]

Answer:

Answer below

Explanation:

Maximum transmission unit (MTU)

A maximum transmission unit (MTU) is the largest packet or frame size that is usually specified in Eight-bit bytes, which can be sent in a packet or frame-based network such as the internet.  

Longest Prefix Match

Longest prefix match is an algorithm used by routers in Internet Protocol to lookup the IP prefix that will likely be the terminal point of the next hop from the router.

CIDR and Subnet Mask

CIDR, known in full as Classless inter-domain routing, is a set of IP standards that is used to make customized identifiers for networks and individual devices.  

A subnet mask separates the internet protocol (IP) address into the network address and host address.

 

Switching Fabric

Switching fabric is simply an arrangement of the elements of a communication network also known as network topology, whereby the nodes of the network are seen to interconnect with one or more network switches.

7 0
3 years ago
Read 2 more answers
Which of the following statements is true of alert files?
ozzi

Answer:

They are only generated by Wireshark.

3 0
2 years ago
A ___________ organizes related commands together, under a tab.
notsponge [240]
A menu bar organizes related commands together, under a tab.
So the answer is <span>b. menu bar</span>
8 0
3 years ago
Using the C language, write a function that accepts two parameters: a string of characters and a single character. The function
Sav [38]

Answer:

#include <stdio.h>

void interchangeCase(char phrase[],char c){

  for(int i=0;phrase[i]!='\0';i++){

      if(phrase[i]==c){

          if(phrase[i]>='A' && phrase[i]<='Z')

              phrase[i]+=32;

          else

              phrase[i]-=32;      

      }

  }

}

int main(){

  char c1[]="Eevee";

  interchangeCase(c1,'e');

  printf("%s\n",c1);

  char c2[]="Eevee";

  interchangeCase(c2,'E');

  printf("%s\n",c2);    

}

Explanation:

  • Create a function called interchangeCase that takes the phrase and c as parameters.
  • Run a for loop that runs until the end of phrase and check whether the selected character is found or not using an if statement.
  • If the character is upper-case alphabet, change it to lower-case alphabet and otherwise do the vice versa.
  • Inside the main function, test the program and display the results.
8 0
3 years ago
True or false: all blockchains are programmed to have the same block time (confirmation time) as each other.
wariber [46]

Answer:

False

Explanation:

<em>The complexity of the hash, which is the hexadecimal number produced by the hashing process, determines the precise length of time required for block production. Thus, block times won't always be the same.</em>

4 0
1 year ago
Other questions:
  • Which windows tool is used to determine if a dynamic disk is corrupted?
    6·1 answer
  • Yan wants to attract customers specifically searching on Google for Time-B-Gone, his company's unique office-support product. Hi
    12·1 answer
  • Which Command Prompt commands in Windows is used for listing a computer connections to shared resources
    10·1 answer
  • You use a(n) ____ variation when a use case is less specific than others, and you want to be able to substitute the more specifi
    8·1 answer
  • The _____ element, a hypertext markup language (html) metadata element, contains a collection of metadata elements that describe
    11·2 answers
  • The 2 main types of copyright relevant to the recording industry?
    5·2 answers
  • 6. A distribution consists of three components with frequencies 200, 250 and 300 having means
    14·1 answer
  • The standing toe touch is most likely to result in
    15·1 answer
  • Which of the following attacks seeks to introduce erroneous or malicious entries into a server's hostname-to-IP address cache or
    5·1 answer
  • List at least 5 professions for people working in the Information/Communication<br> fields.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!