K&R: Chapters 5.1-5.10.
Submit your solution online by 8pm on 27th June 2004. Do this by creating a directory named hw1-2 that contains the file baseconvert.c. From within that directory, type
submit hw1-2This is not a partnership assignment ; hand in your own work, and don't collaborate with anyone else.
Write a C program called baseconvert.c that takes three command line arguments: a numeral (may be negative or non-negative), the radix (base 10) used to represent that numeral, and an output radix (also base 10). Your program should print the value represented by the numeral as interpreted in the input radix, translated into the output radix. For example,
command | output | notes |
baseconvert 43 8 10 | 35 | 43 base 8 = 35 base 10 |
baseconvert fff 16 10 | 4095 | fff base 16 = 4095 base 10 |
baseconvert 1001 2 7 | 12 | 1001 base 2 = 12 base 7 |
baseconvert -abx 36 19 | -1i1d | -abx base 36 = -1i1d base 19 = -(1*6859 + 18*361 + 1*19 + 13) |