Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C# Write a program that uses a recursive method to convert a number in decimal to a given base b, where b is between

In C#

Write a program that uses a recursive method to convert a number in decimal to a given base b, where b is between 2 and 36. Your program should prompt the user to enter the number in decimal and the desired base.

Hint: The algorithm to convert a positive decimal number into an equivalent number in octal (or hexadecimal) starts by dividing the decimal number by 8 (for octal) and by 16 (for hexadecimal). Suppose that ab represents a to the base b. Then 7510 represents 75 base 10 (decimal) and 7516 represents 75 base 16 (hexadecimal). Check out these equivalents:

75310 = 13618

75310 = 2F116

You can extend the idea of converting from a decimal to base 2, 8 or 16 to any base. Suppose you wish to convert a decimal number n into an equivalent number in base b, where b is between 2 and 36. You would start by dividing the number n by b. Note: the digits in say base 20 are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I and J.

You need to write your program and test it using the test cases below. You will need to start by writing the pseudocode for your programs, then code the solution and test your solution.

Test Data Inputs:

9098, base 20

692, base 2

753, base 16

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

3. How frequently do the assessments occur?

Answered: 1 week ago