Question: The second laboratory exercise requires you to code the following conversion schema in theC language. Question 1 - Base number conversion.The programming exercise requires you

The second laboratory exercise requires you to code the following conversion schema in theC language.
Question 1- Base number conversion.The programming exercise requires you to code the general algorithm to convert any numericbase system number to base 10(decimal). This implies any base system from base 2(binary)to base 9. The following algorithm gives the description of the procedure.
Algorithm 1 Base b conversion to decimal
Input: A number dn1dn2... d1d0 in base b
Output: Equivalent decimal number
1: procedure The digits of the input number are processed from left to right one digit at a time.
Result =0
for (i = n 1 downto 0) do
Result =(Result x b)+ di
end for
return Result
end procedure
Using Algorithm 1 as the template, code the conversion routine. You are not allowed to useany inbuilt language specific conversion commands. Your code should be able to convert anybase from 2 till 9 to decimal.
The algorithm should do the following:
1. Ask the user to enter the required base.
2. Check if the base is between 2 and 9 inclusive.
3. If not, ask the user again to enter the base.
4. Using the given equation, compute the decimal equivalent number in a for loop startingfrom the left to the right.

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 Programming Questions!