Question: 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
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 (1 x 24 + 0 x 23 + 0 x 22 + 0 x 2 + 1 = 17). So, bin2Dec("10001") returns 17. Write a test program that prompts the user to enter a binary number as a string and displays its decimal equivalent value.
Step by Step Solution
3.49 Rating (149 Votes )
There are 3 Steps involved in it
To tackle the problem well write a function named bin2Dec that converts a binary string to a decimal number based on its binary representation Well th... View full answer
Get step-by-step solutions from verified subject matter experts
