Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions