Question: Programming Exercise (25 points): (Call the Source code Exercisel.c) Write a routine/function that takes as input a character c supposed to be a binary digit

 Programming Exercise (25 points): (Call the Source code Exercisel.c) Write a

Programming Exercise (25 points): (Call the Source code Exercisel.c) Write a routine/function that takes as input a character c supposed to be a binary digit and returns an integer representing the value of the digit c. If c is not a binary digit, your function must return -1. Use this function to implement a program that prompts the user to enter a character c that represents a binary digit (a bit) (Recall that c can be only '0' or'l). Your program must use the character type for the input. If the user enters a character x' that is NOT a binary digit, you must print out the error message: "The characterx is invalid: x is not a bit"If the character c is a bit, your man program must return an integer representing the value of the digit and print out that value in decimal. Example I: If the user enters the character '0, your program must print out the value 0. Example 2: If the user enters the character, your program must print out the value Example 4: If the user enters the character 'B', your program must print out the error message: The character B is invalid: B is not a bit

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!