Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include #include #define SIZE 32 // maximum size of the binary number is 32 bit. // Define the prototypes for functions used in the
#includePart 1: Programming (80%) Refer to lab2.c file posted on blackboard, finish functions to print out a given unsigned/signed number into its binary number. The following screenshots are as demos what you should have on your output screen. Pay special attention to "//finish this part...." comments. Case 1: Input a positive number: *******Please select the following options** 1. Convert Integer Number to Binary. (Lab 2) 2. Binary number to signed decimal number conversion.(lab 3) 3. Binary number to Floating number conversion (Lab 3) e. To Exit, Type 'e' 1 Please input your integer decimal number: 12 00000000 00000000001100 Case 2: Input a negative number: **********Please select the following options*** 1. Convert Integer Number to Binary. (Lab 2) 2. Binary number to signed decimal number conversion. (Lab 3) 3. Binary number to Floating number conversion (Lab 3) e. To Exit, Type 'e' ****** 1 Please input your integer decimal number: -20 11111111111111111111111111101180#include #include #define SIZE 32 // maximum size of the binary number is 32 bit. // Define the prototypes for functions used in the code. /* Prototypes Definitions*/ void printbinary(int number); void convert_binary_to_signed(char *binary); void convert_binary_to_float(char *binary); char *menu = " " \ " " \ "=================================================================== " \ "************Please select the following options******************** " \ " * 1. Convert Integer Number to Binary. (Lab 2) * " \ " ******************************************************************* " \ " * 2. Binary number to signed decimal number conversion.(Lab 3) * " \ " * 3. Binary number to Floating number conversion (Lab 3) * " \ " ******************************************************************* " \ " * e. To Exit, Type 'e' * " \ " ******************************************************************* "; // *Lab 2*. The code needs to convert unsigned number into 32-bit binary format and // display it on screen. For example, if input number is 14, you // should be able to display 00000000000000000000000000001110 on the screen. If input number is 256, you // should display 00000000000000000000000100000000 on the screen. See the screen shot on the lab manual as // a reference of 32-bit display example. // Function to convert decimal number into 32-bit binary and display. void printbinary(int number) { } // Function to convert a binary input into a signed decimal number. // Lab 3 void convert_binary_to_signed(char *binary) { } // Function to convert a 32-bit binary input into a floating number. // Lab 3 void convert_binary_to_float(char *binary) { } // No need to touch main function in lab 2 and lab 3. int main(void) { char options; // the option should only be a byte char inputs[33] = {0}; // 32-bit string plus a ending indicator. int decimal_in = 0; do{ puts(menu); /* prints Memory Simulation */ fflush(stdin); // clear the input buffer before getchar. options = getchar(); switch (options) { case '1': // lab 2 Convert an integer number to binary and display puts("Please input your integer decimal number:"); scanf("%d", &decimal_in); printbinary(decimal_in); continue; case '2': /* lab 3. Convert binary number into a SIGNED decimal number and display */ puts("Please input your BINARY number, "\ "I will convert it to signed decimal:"); scanf("%s", &inputs[0]); // Input must be a string with 0/1 convert_binary_to_signed(inputs); continue; case '3':/* lab 3. Convert 32-bit binary number into a floating * point number number and display */ puts("Please input your 32-bit floating point number " \ "in binary, I will convert it to decimal"); scanf("%s", &inputs[0]); // Input must be a string with 0/1 convert_binary_to_float(inputs); continue; case 'e': puts("Code finished, exit now"); return EXIT_SUCCESS; default: puts("Not a valid entry, exit now"); continue; } }while (1); }
Step 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