

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CSC 3210 โ Assignment # Summer 2008 due Friday, August 1st, by midnight no late assignments accepted Overview: This program will present the user with a short menu and process their input accordingly using subroutines. The program will ask the user to select one of three options: Extract, Set, or Quit. If the user selects either Extract or Set, then the program will either extract a field from the predefined value, or it will set bits of a field for the value. The user will enter the position of the least significant bit of the field and the number of bits in the field. The program should then display the initial value in binary and the result in binary and its parity and then prompt the user with the menu once again. If the user selects the Quit option, then the program should end. You should write subroutines called Extract, Set_Field, and Parity. Define a constant called value to equal 1242 10 = 0100110110102. The TA may change this value while testing your program. You should confirm that the user inputs are valid. If not, then print out an appropriate message and prompt the user once again. The values entered for the lsb and length will be single digit numbers. Use scanf to read input from the keyboard and printf to display your message on the monitor. Example: Here is an example of what your program will do: Please select one of the following functions: e : Extract bits of a field s : Set bits of a field q : Quit this program The user will then type in a character followed by the ENTER key. Your program will respond accordingly. Assume the user enters โeโ. Please enter in the lsb of the field: Assume the user enters โ4โ. Please enter in the length of the field: Assume the user enters โ6โ. The initial value in binary is: 00000000000000000000010011011010
The result in binary is: 00000000000000000000000000001101 The parity of the result is: Odd Please select one of the following functions: e : Extract bits of a field s : Set bits of a field q : Quit this program โฆ As usual, make sure to document your code properly/