Question: ( C++ ) a. Write a function that returns a decimal number from a binary string. The function header is as follows: int bin2Dec(const string&
( C++ )
a. Write a function that returns a decimal number from a binary string. The function header is as follows: int bin2Dec(const string& binaryString) For example, binaryString 10001 is 17 (1x24 + 0x23 + 0x22 + 0x21 +1x20 =17). So, bin2Dec("10001") returns 17.
b. Write a function that parses a decimal number into a binary number as a string. The function header is as follows: string dec2Bin(int value) For example, dec2Bin (17) returns string 10001.
c. Write a test program that prompts the user to enter a binary or decimal number and display its equivalent value in decimal or binary. (20 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
