Question: Write a code in C that converts binary to decimal, If the user enters number other then 0 or 1 please write Number is not
Write a code in C that converts binary to decimal, If the user enters number other then 0 or 1 please write "Number is not a 0 or 1" if the user enters a blank please say "nothing entered" and print 0. if the user types in letters please indicate that the user typed in a letter. here is the starter code and instructors. 


Instructions: You will write a program bindec.c that will take binary numbers as input, and output the decimal equivalent. I provide code you will use as a starting point. 5. Your code should respond to empty input with value 0, and should respond to invalid input with message 'input must contain only zeros and ones', and exit with value 1, indicating an error. Your code should be able to handle inputs of at least 20 binary digits. Some examples of how your program should work: $ gcc -o bindec bindec.c $ ./bindec > 1001 9 $ ./bindec > 11111111 255 $ ./bindec > hello input must contain only zeros and ones $ ./bindec (no input given, just hit 'enter') 0 > 2 hw1 ) hw1 ) c main) No Selection #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
