Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C, how can I take in a char array and then split it into three different variables (What the user enters)? I assume I
In C, how can I take in a char array and then split it into three different variables (What the user enters)? I assume I need to read in the two binary numbers as integers then perform the conversion to decimal to do the math then back to binary again. How do I do this?
Operation The program should continually accept a binary arithmetic command and perform the arithmetic given. Input The default input command should have the form: Operandl Operation Operand2 [ENTER] where Operation is either +, -, x, or /, and the operands, Operandl and Operand2, are binary numbers of no more than 31 bits each. The program should continue to take in arithmetic commands until the string "quit" is entered which should make the program terminate after saying "Good bye". Output When your program first runs, it should output the format of the input it is looking for. If the input is invalid, i.e., the operator is anything other those specified, or the operators are anything other than two binary numbers no longer than 31 bits, the program should print a clear and concise error message and reprint the desired format for the input. If the input is valid, the program should display the result of the operation preceded by an equals sign. For example, if the user inputs apollo13% 1011 + 1001 then the output should be = 10100 Things to Consider When performing subtraction, the second operand should be subtracted from the first. When performing division, the first operand should be divided by the second using integer division and both the quotient and remainder should be displayed. There are many ways to write this program, but some ways are easier than others, especially for beginner programmers. I would suggest using your knowledge from digital logic class to convert the numbers input into "decimal numbers (which are stored in binary in the computer of course.) The numbers should be input as two strings, that is, arrays of characters (which are ASCII codes for ones and zeroes) because scanf has no binary input format. Then you can perform the arithmetic on these "decimal" variables and print out their binary equivalent of the decimal number using the decimal-to-binary conversion method learned in ECE 2010Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started