Question: Copyright 2013, Dennis Rainey HW 5a-Recursion Decimal to binary 1.) The following is the algorithm to convert a decimal number (int) to a binary number

 Copyright 2013, Dennis Rainey HW 5a-Recursion Decimal to binary 1.) The

following is the algorithm to convert a decimal number (int) to a

Copyright 2013, Dennis Rainey HW 5a-Recursion Decimal to binary 1.) The following is the algorithm to convert a decimal number (int) to a binary number Page 1 of 2 Ex: Convert 13 to 1101 a) First divide the integer number by 2, (binary is base 2). Ex: int num = 5; int base 2; -5- 2 with a remainder of 1 b) Write down the remainder c) Then divide the new number by two and write down the number Each time the new number is the quotient from the previous expression. 21 with a remainder of 0 Write the remainders moving from right to left. - d) Repeat steps a and b until the new number (quotient) is o 0 with a remainder of 1 Answer? 101 2.) Write a program that converts integer values to binary 3.) Your program should first prompt the user to enter a non-negative integer 4.) The program should have a recursive function named: decToBinary The int values should be 0 or greater With the - The function is void-returning. - The function divides the number that is passed as an argument by 2 - The remainder is output to the screen. first function call in main), an integer value, initially representing the value entered by the user is passed to the function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!