Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

7. List behaviors to improve effective leadership in meetings

Answered: 1 week ago

Question

6. Explain the six-step group decision process

Answered: 1 week ago