Question: Program #2 Write a program to convert binary numbers to decimal. The program asks the user for a binary number (0's and 1's) and returns

Program #2 Write a program to convert binary numbers to decimal. The program asks the user for a binary number (0's and 1's) and returns the equivalent in decimal. In order to do so, you need to a) get the length of the string, b) based on the symbol and its position, determine the value in decimal. Binary numbers can be converted to decimals using the expansion formula: n-1 b= bo * 100 +b, * 101 +b, * 102 + + b"- * 10"-1 Where the binary number is given as Binary b-1-2 Position n-1 n- 210 n bits The value of each bit(binary digit), depends on its position Binary bi-1 Position n-1 Decimal Value10-10-1 210 021010 A) (10 points) Write a function that receives a c-string, and determines if a) is a valid c-string and b) it is a valid binary number (i.e. it contains only O's and 1's). The function will return 1 if the string is valid and 0 otherwise B) (30 points) Write a function that receives a valid binary c-string (i.e. is a valid c string and contains only O's and l's), its length and size and converts to a decimal number. The function will receive only c-strings representing integer numbers > 0 Deliverables C source code file. Make sure to include enough comments (or any other instruction) to execute your program The C source code file should: 1) Comply with all of the formatting requirements already discussed. 2) Display the output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
