Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer these two questions: (Please do not copy other answers online, thank you) 1. A listing of your program (.c and .h files). 2.
Please answer these two questions: (Please do not copy other answers online, thank you)
1. A listing of your program (.c and .h files).
2. Output that demonstrates that the code performs correctly. Your output must demonstrate that
Purpose: The objective of this project is to gain experience with C language preprocessor directives and bit-wise operators. 1.) header file: In addition to a .c file, also write and use a header (.h) file. Include in this header file your \#define statements and other appropriate items. 2.) main routine: The main routine is to loop displaying a menu of options and then to perform the selected operation on an input integer number. The operations to be displayed / performed are the following: - display number in designated base - shift number left circular by one digit in the designated base - shift number right circular by one digit in the designated base - take the one's complement of the number Note: for all operations, the final result is to be displayed in the designated base (see next item). 3.) display routine: Write one function that takes an integer value as an input argument and then displays the number in the designated base. The base is either binary or hexadecimal. The selection of base is to be made at compile time via the D option. Instead of having two separate routines, one for binary and one for hexadecimal, you are to write one routine some of whose statements vary based on the selection of base. This variation of statements is to be controlled via conditional preprocessor directives. 5.) Shift left/right macros: Write two macros. SRC is to take the argument and shift it right circular by one digit in the designated base. The other, SLC, is to take the argument and shift it left circular by one digit in the designate base. So, for example, if value is OxOAOBOCOD initially, then it must be possible to use the SLC macro as follows: value =SLC (value; and value should then contain OxAOBOCODO. The macros are to be inline code; that is, they are not to call any function to produce the result. Your program must use these macros to process the shift menu options. 6.) Readability: Your program must be written using good C programming conventions: - Variable names and function names should be descriptive of what they represent; for example, if you have a variable into which you read the menu option, then you might name the variable option. - Use indentation to show the structure of the program. Typically this means using indentation with for, while, do-while, if, and switch statements as well as indenting the body of functions. Indentation should show the nesting level of the statements involved. - Include some in-line documentation to give a high level view of what the program and groups of statements is/are doing. Sample output: (execute the version of the code with hexadecimal output) Input number 2271560481 Select option 1 - display number in hexadecimal 2 - shift left circular one digit 3 - shift right circular one digit 4 - complement 5 - exit 1 087654321 Select option 1 - display number in hexadecimal 2 - shift left circular one digit 3 - shift right circular one digit 4 - complement 5 - exit 2 076543218 Select option 1 - display number in hexadecimal 2 - shift left circular one digit 3 - shift right circular one digit 4 - complement 5 - exit 3 087654321 Select option Ox18765432 (after termination, execute the version with binary output) Input number 2153791520 Select option 1 - display number in binary 2 - shift left circular one digit 3 - shift fight cifcular one digit 4 - complement 5 - exit I 10000000011000000100000000100000 Select option 1 - display number in binary 2 - shift left circular one digit. 3 - shift right circular one digit 4 - complement 5 - exit 3 Select option 1000000001100000010000000010000 - display number in binary 2 - shift left circular one digit 3 - shift right circular one digit 4 - complement 5 - exit 4 10111111110011111101111111101111 Please answer these two questions: 1. A listing of your program (.c and.h files). 2. Output that demonstrates that the code performs correctly. Your output must demonstrate that Purpose: The objective of this project is to gain experience with C language preprocessor directives and bit-wise operators. 1.) header file: In addition to a .c file, also write and use a header (.h) file. Include in this header file your \#define statements and other appropriate items. 2.) main routine: The main routine is to loop displaying a menu of options and then to perform the selected operation on an input integer number. The operations to be displayed / performed are the following: - display number in designated base - shift number left circular by one digit in the designated base - shift number right circular by one digit in the designated base - take the one's complement of the number Note: for all operations, the final result is to be displayed in the designated base (see next item). 3.) display routine: Write one function that takes an integer value as an input argument and then displays the number in the designated base. The base is either binary or hexadecimal. The selection of base is to be made at compile time via the D option. Instead of having two separate routines, one for binary and one for hexadecimal, you are to write one routine some of whose statements vary based on the selection of base. This variation of statements is to be controlled via conditional preprocessor directives. 5.) Shift left/right macros: Write two macros. SRC is to take the argument and shift it right circular by one digit in the designated base. The other, SLC, is to take the argument and shift it left circular by one digit in the designate base. So, for example, if value is OxOAOBOCOD initially, then it must be possible to use the SLC macro as follows: value =SLC (value; and value should then contain OxAOBOCODO. The macros are to be inline code; that is, they are not to call any function to produce the result. Your program must use these macros to process the shift menu options. 6.) Readability: Your program must be written using good C programming conventions: - Variable names and function names should be descriptive of what they represent; for example, if you have a variable into which you read the menu option, then you might name the variable option. - Use indentation to show the structure of the program. Typically this means using indentation with for, while, do-while, if, and switch statements as well as indenting the body of functions. Indentation should show the nesting level of the statements involved. - Include some in-line documentation to give a high level view of what the program and groups of statements is/are doing. Sample output: (execute the version of the code with hexadecimal output) Input number 2271560481 Select option 1 - display number in hexadecimal 2 - shift left circular one digit 3 - shift right circular one digit 4 - complement 5 - exit 1 087654321 Select option 1 - display number in hexadecimal 2 - shift left circular one digit 3 - shift right circular one digit 4 - complement 5 - exit 2 076543218 Select option 1 - display number in hexadecimal 2 - shift left circular one digit 3 - shift right circular one digit 4 - complement 5 - exit 3 087654321 Select option Ox18765432 (after termination, execute the version with binary output) Input number 2153791520 Select option 1 - display number in binary 2 - shift left circular one digit 3 - shift fight cifcular one digit 4 - complement 5 - exit I 10000000011000000100000000100000 Select option 1 - display number in binary 2 - shift left circular one digit. 3 - shift right circular one digit 4 - complement 5 - exit 3 Select option 1000000001100000010000000010000 - display number in binary 2 - shift left circular one digit 3 - shift right circular one digit 4 - complement 5 - exit 4 10111111110011111101111111101111 Please answer these two questions: 1. A listing of your program (.c and.h files). 2. Output that demonstrates that the code performs correctly. Your output must demonstrate thatStep 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