- Your program will perform conversion from decimal representation to two’s complement binary representation of integers, using recursive control. Your program needs to:
- 1. Read in an integer value from a file named input6.txt.
- 2. Convert the input decimal value to two’s complement. Note: The first entry in input6.txt specifies the minimum number of bits to be used to display the number in two’s complement notation.
- 3. Output to output6.txt the original decimal value and its two’s complement form using at least n bits for the length of the binary.
- These steps must be repeated as long as there are decimal numbers in the input file.
- You must develop the algorithm first and then implement it. Use pseudocode for representing the algorithm. The algorithm must be detailed up to a level that shows the control structures (if, if-else, while, etc) needed.
- Function main() must call function string convert(int decimal, int n) that receives the number and returns a string that represents the corresponding binary number in n bits format, where n is the minimum number of bits used to display the binary number.
- Function convert() will have to call the recursive function string dectobin(int decimal) that receives the decimal number and returns a string that represents the corresponding binary number in free format (that is, with just as many bits as needed to represent the value). Thus, it is the task of convert() to add the 0’s (or 1’s) to the string returned by dectobin() so that the binary number is in n bits format.

asdf

By: asdf | Date: Nov 24 2007 21:53 | Format: None | Expires: never | Size: 1.51 KB | Hits: 853

Latest pastes

14 months ago

15 months ago

15 months ago

15 months ago

15 months ago