Question: CODE IN C Task 2 : String to number In this task, you will ask the user for a string x that represents a real

CODE IN C Task 2: String to number
In this task, you will ask the user for a string x that represents a real number and the base b in which this number iven. Your task is to convert this string in to the floating number in base 10.
Note. Number in base 10 are the numbers we use in our daily basis were all the number's digits are less than 10.
Example:
x=75.32,b=8, Output:61.40625
Explanation:
-7*81=56
-5*80=5
-3*8-1=0.375
-2*8-2=0.03125
Output: 56+5+0.375+0.03125=61.40625
x=-75.32,b=8, Output: -61.40625
1
x=101.01,b=2, Output:5.25
Explanation:
-1*22=4
-0*21=0
-1*20=1
-0*2-1=0
-1*2-2=0.25
- Output: 4+0+1+0+0.25=5.25
x=134.51,b=5, Output: 0
Explanation: The input is in base 5 so all the digits must be less than
5. Otherwise the input is wrong. In this cases, we return 0.
Constraints: Consider the string will contain the following characters:
digits: '0','1','2','3','4','5','6','7','8','9'.
symbols: '-',',
Subtasks:
Create a function to check if the given input is valid. Must finish in Lab
Create a function to convert a string into an positive integer. Assume that the input will not have decimal part and that it is positive. Must finish in Lab
Modify the previous function to include integer numbers. Assume that the input will not have decimal part. Must finish in Lab
Modify the previous function to include floating numbers.
Built-in functions are NOT allowed.
 CODE IN C Task 2: String to number In this task,

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