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

1. Your program will perform conversion from decimal representation to two抯 complement binary representation of integers, using recursive control.  Your program needs to:
2. 1.      Read in an integer value from a file named input6.txt.
3. 2.      Convert the input decimal value to two抯 complement. Note: The first entry in input6.txt specifies the minimum number of bits to be used to display the number in two抯 complement notation.
4. 3.      Output to output6.txt the original decimal value and its two抯 complement form using at least n bits for the length of the binary.
5.         These steps must be repeated as long as there are decimal numbers in the input file.
6.
7.         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.
8.         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.
9.         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抯 (or 1抯) to the string returned by dectobin() so that the binary number is in n bits format.