Classwork 16: Converting to Binary
Wednesday, May 09, 2012[Previous Classwork] [Next Classwork]
Complete the following:
- Create a file named cw16.c
- You are to write a program that will accomplish the following:
- Prompt the user to either convert decimal to binary or binary to decimal.
- Read in either a decimal or binary number as a string.
- Convert the number to the other format.
- Print your solution.
- Repeat step 1 until the user enters "quit"
- For Extra credit, add functionality that will allow a user to convert decimal to hexadecimal and vice versa.
- For Extra Extra credit, add functionality that will allow a user to convert between octal and decimal. You will have to look this one up online.
- For Extra Extra Extra credit, add functionality that will act as follows:
D - Decimal
B - Binary
H - Hexadecimal
O - Octal
Please select the input format: D
Please enter your Decimal number: 64
Decimal Binary Hexadecimal Octal
--------------------------------------------
64 0b100000 0x40 0o100
- Once you are done, use submit to submit one file,
linux3[26]% submit cs104 cw16 cw16.c
- After submitting your file, you can verify your file was submitted by using the submitls command
- MAKE SURE YOU LOGOUT AFTER SUBMITTING THE ASSIGNMENT AND BEFORE LEAVING CLASS!