//Name: Jonathan Linder //Date: January 31, 2006 //Class: ECE 222 //Section: 001 //Professor: Dr. Hoover //Purpose: To write a program that does simple binary math. /*The user inputs a string (ex: 10010101+1110010) and the program will separate the string into 3 parts. The first part being the first number. The second part being one of four operators(+ - * /), and the third part being the last number. Once the string is broken into 3 parts the numbers are converted into decimal and then the calculations are made. The final answer is then converted back into binary and displayed for the user to see*/ #include #include int main(){ int i; char input[50]; char first[14]; char second[14]; printf("\nPlease input your string in this format with no spaces, brackets, parenthesis, commans, colons, semi-colons or any other seperations that you can think of.\n"); printf("Format: (binary #1)(logic operater(+ - * /))(binary #2)\n"); printf("Input: "); scanf("%s", &input); i=0; for(i=0; i<=strlen(input); i++){ if (input[i]=='1' || input[i]=='0'){ first[i]=input[i]; } else{ printf("Your operation %s is not in the specified form!\n", input); continue; } } printf("First binary number: %s\n", first); return 0; }