Question: Write a program that asks the user to enter a decimal integer number and then converts it binary (base 2) and prints it out. The

Write a program that asks the user to enter a decimal integer number and then converts it binary (base 2) and prints it out. The algorithm for converting a decimal to binary involves continually dividing the decimal number by the base (in this case, 2) and saving the remainder. For example, let us convert the number 57 to binary 57 2- 28 rem 28+2-14 rem 0 142=7 72-3 rem 0 rem 1 rem 1 rem 1 1-2=0 The binary number consists Here is some sample output: of the remainders read from the bottom up, i.e. 1 1 1001 Enter a decimal (base 10) number 57 The decimal number 57 in binary (base 2) is 111001 Hint: You will need to use an integer array to store the remainders and then print them in reverse order. Assume that it can deal with 16 bits in total
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
