Question: CS 1325 Assignment #4 C-Strings Program #2 Progra m #2 Write a program to convert binary numbers to decimal. The program asks the user for

CS 1325 Assignment #4 C-Strings Program #2

CS 1325 Assignment #4 C-Strings Program #2 Progra m #2 Write a

Progra m #2 Write a program to convert binary numbers to decimal. The program asks the user for a binary number (0's and 1s) 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: bl = bo * 100 + b1 * 10' + b2 * 102 + + bn-1 * 10"-1 Where the binary number is given as: Binar Position n-1 bu-2 n- 21 0 n bits The value of each bit(binary digit), depends on its position: Binary bn-1 bn2 Position n-1 Decimal Valuc 0 10-1 10 100 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 I'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 0'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 cnough 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!