Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C language Problem 1. a. Write a program to convert a number from decimal notation to a number expressed in a number system whose

Using C language
image text in transcribed
Problem 1. a. Write a program to convert a number from decimal notation to a number expressed in a number system whose base (or radix) is a number between 2 and 9. The conversion is performed by repetitious division by the base to which a number is being converted and then taking the remainders of division in the reverse order. For example, in converting to binary, number 6 requires three such divisions: 6/2=3 remainder 0,3/2=1 remainder 1, and finally, 1/2=0 remainder 1. The remainders 0, 1, and 1 are put in reverse order so that the binary equivalent of 6 is equal to 110. b. Modify the program in part (a) so that it can perform a conversion in the case when the base is a number between 11 and 27. Number systems with bases greater than 10 require more symbols. Therefore, use capital letters. For example, a hexadecimal system requires 16 digits: 0, 1,..., 9, A, B, C, D, E, F. In this system, decimal number 26 is equal to 1A in hexadecimal notation because 26/16 = 1 remainder 10 (that is, A), and 1/16=0 remainder 1. Example of a running demonstration: Please enter a decimal number: 6 Please enter the conversion base: 2 Your base 2 representation of the number 6 is: 110 Note: Using stack to solve the above problems. You are free to decide internal representation of the Stack (arrays or linked list). You can design a separate algorithm for each part OR generalize it to one algorithm for both parts

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions