Question: Display the decimal number in console. The output should be formatted exactly in the shown invocation samples. Please enter a base from 2 - 9

Display the decimal number in console.
The output should be formatted exactly in the shown invocation samples.
Please enter a base from 2-9:2
Enter a base 2 number: 100101
The equivalent number in base 10 format is 37
Please enter a base from 2-9: 16
Incorrect base system. Please enter a base from 2-9:
Please enter a base from 2-9: 8
Enter a base 8 number: 247
The equivalent number in base 10 format is 167
The second laboratory exercise requires you to code the following conversion schema in the C language.
Question 1- Base number conversion.
The programming exercise requires you to code the general algorithm to convert any numeric base 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.Using Algorithm 1 as the template, code the conversion routine. You are not allowed to use any inbuilt language specific conversion commands. Your code should be able to convert any base from 2 till 9 to decimal.The algorithm should do the following:
Ask the user to enter the required base.
Check if the base is between 2 and 9 inclusive.
If not, ask the user again to enter the base.
Using the given equation, compute the decimal equivalent number in a for loop starting from the left to the right.
1
Display the decimal number in console.
The output should be formatted exactly in the shown invocation samples.
Please enter a base from 2-9:2
Enter a base 2 number: 100101
The equivalent number in base 10 format is 37
Please enter a base from 2-9: 16
Incorrect base system. Please enter a base from 2-9:
Please enter a base from 2-9:8
Enter a base 8 number: 247
The equivalent number in base 10 format is 167
Display the decimal number in console. The output

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!