Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are required to write a C++ program that creates uses recursion to convert a number to its binary. Your program should have a class

image text in transcribedimage text in transcribed
You are required to write a C++ program that creates uses recursion to convert a number to its binary. Your program should have a class Conversion with following details: 0 private 0 chor'l' char_number; 0 public 0 ConversionCconst chor' *number) I A parameterized constructor that takes a number in the form of a character array, calculates the size of the array received as a parameter and creates a space in the heap memory with size + 1. This constructor should also make the private data member char* char_number point to this heap memory location and copy the content of number to char_number. O void DecimalToBinary(int n) I This function should be able to convert the number from its decimal form to binary. This function should be recursive in nature. It may not have any loops. 0 void convertO I This function should convert char_number to an integer and call the DecimalToBinary(int n) function for conversion. 0 ~Conver'sionO I This destructor should be able to deallocate the memory used by char_number along with making char_number point to null pointer. Your main method should have char numberElG] which is used to take an input of a number in the form of a characters (character array) from the user. Once the input is taken from the user, use the following lines in the main method to begin the process of conversion. Your main method should have char' number[1@] which is used to take an input of a number in the form of a characters (character array) from the user. Once the input is taken from the user, use the following lines in the main method to begin the process of conversion. Conversion conversion = ConversionCnumber); conversion.convert(); You can only use and libraries. Below is the screenshot of the expected output of this program: Enter an integer to convert to binary: 99 Binary of 99 is: 1160611

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

=+ c. What is investment as a percent of output for each country?

Answered: 1 week ago