hello can someone help me with a program for school ive been working on it for 2 weeks and apparently ive been doing it all wrong and trashed it. I was about to give up on it and then i found this website. Please can someone help out. Im attaching a file on what needs to be done......never mind i cant find where to attach a file at so heres what needs to be done
Functions with a string parameter: Write a C++ program which can convert between a decimal integer and
the binary format of this number stored as a C-string of ones and zeros. Your program must include the functions
find binary() to convert from decimal to binary and find int() to convert from binary to decimal. It must offer
the user a choice of converting from decimal to binary, or from binary to decimal, or quitting. Based on the user’s
choice, it must do the conversion requested and display the result, then repeat the menu until the user selects to
quit.
Requirements:
• Your functions must have the following function prototypes:
void find_binary(int num, char str[]);
int find_int(char str[]);
The find binary function calculates the binary format for the number it receives through its parameter num
and stores the result in its parameter str. The function find int calculates the decimal number for its
parameter str and returns the result.
• The decimal number in the conversion must be stored as a variable of type int. Note that an actual binary
data type is not used – instead, the binary format of numbers converted must be stored as a C-string of 1’s
and 0’s.
• The program only needs to work for positive integers. Negative numbers, numbers containing fractions, and
any input which doesn’t correctly represent a postive integer (in decimal or binary format, as required), will
not be used to test the program.
• Name the source file for your program program7.cpp
• Use comments to show the main steps in the program, to document variable declarations, and at the top of
each function to briefly describe what it does.
• A sample run of your program should look like:
Available choices:
1. Display a decimal integer in binary format
2. Convert from binary format to a decimal integer
3. Quit
Enter the number of your choice: 1
Enter an integer: 29
The decimal number 29 has the binary format 11101.
Available choices:
1. Display a decimal integer in binary format
2. Convert from binary format to a decimal integer
3. Quit
Enter the number of your choice: 2
Enter a binary number (as 0’s and 1’s): 110100
The binary number 110100 has the decimal value 52.
Available choices:
1. Display a decimal integer in binary format
2. Convert from binary format to a decimal integer3. Quit
Enter the number of your choice: 3
Hints:
• The conversions back and forth between decimal and binary formats are not difficult, but they do require
some care. If you are having trouble with these conversions, work out the conversion by hand for some small
numbers. Once you understand how the method works by hand, then try to duplicate it in your code.
• The integer arithmetic operations (/ and %), and the pow function from the cmath library may be useful.
• Be careful to use data types correctly – for example, the number 1, the string “1”, and the character ‘1’ are all
different.