c language do with this skeleton please atof is a function in the C programming language that
Fantastic news! We've Found the answer you've been seeking!
Question:
c language do with this skeleton please
Transcribed Image Text:
atof is a function in the C programming language that converts a string into a floating-point numerical representation. atof stands for ASCII to float. Task 1. In this part of the assignment, you are going to implement your own atof function float myAtof (char* string, char* error) that will convert an input read as a character array into a floating-point number. ✓ Your atof function will get two inputs. One for the character array to convert and the other to check for the error. The output of the function will be a floating-point number. If the character array cannot be converted (it includes letters, special characters, etc.) the error will be 1, otherwise 0. ✓ ✓ If the numbers cannot be converted (error = 1), give an error message to the user. Here are some sample outputs: Enter a number: 6 Your number is: 6.00 Process returned e (exe) Press any key to continue. Enter a number: 4.678 Your number is: 4.68 Process returned 0 (0x0) Press any key to continue. execution time: 9.563 S execution time: 5.820 s Enter a number: hello Error has been occurred due to inappropriate input! Process returned 0 (0x0) execution time: 3.126 s Press any key to continue. #include #include #define SIZE 250 float myAtof (char *string, char *error); int main() { } char string[SIZE]; float fnum1; char errorState=0; } // Array declaration. printf( Enter a number: ); gets (string); fnum1-myAtof(string, &errorState); if (errorState ==0) { printf( Your number is: %.2f , fnum1); }else if (errorState==1){ printf( Error has been occurred due to inappropriate input! ); } return 0; float myAtof (char* string, char* error) { //your code comes here!!! // Function to convert string into float. In this part of the assignment, you will use your own atof function that you implement in the task 1 to extend arithmetic operation evaluation (+,-,*/) to operate on floating-point numbers. You will get a character array from the user. The user will enter the operation in the form • 1.25 + 12 • 0.24 * 3 etc. The output will be 1.25 12.00 13.25. Do not use the functions of String library. Use gets() function to get the operation from the user. Notice that end of input is indicated by null character \0 Numbers will be printed with two-digit precision after decimal point. ✓ If the user enters an invalid operation, give a message. Here are some sample outputs: Enter arithmetic operation: 0.00 0.00 0.00 Process returned (exe) execution time: 14.202 s Press any key to continue. Enter arithmetic operation: 6-2 6.00 2.00 4.00 Process returned 0 (0x0) execution time: 3.713 s Press any key to continue. Enter arithmetic operation: 3.7/3 3.70 3.00 1.23 Process returned 0 (exe) Press any key to continue. Enter arithmetic operation: 5.3*2.1 5.30 2.10 11.13 Process returned e (exe) Press any key to continue. execution time : 5.604 s execution time : 6.372 s Enter arithmetic operation: 3.7 * 5 Error has been occurred due to inappropriate input! Process returned 0 (0x0) execution time: 10.354 s Press any key to continue. Enter arithmetic operation: 4+hello Error has been occurred due to inappropriate input! Process returned 0 (0x0) execution time: 7.720 s Press any key to continue. Process returned 0 (0x0) Press any key to continue. Enter arithmetic operation: 4/0 Cannot divided into 0. execution time: 4.016 s atof is a function in the C programming language that converts a string into a floating-point numerical representation. atof stands for ASCII to float. Task 1. In this part of the assignment, you are going to implement your own atof function float myAtof (char* string, char* error) that will convert an input read as a character array into a floating-point number. ✓ Your atof function will get two inputs. One for the character array to convert and the other to check for the error. The output of the function will be a floating-point number. If the character array cannot be converted (it includes letters, special characters, etc.) the error will be 1, otherwise 0. ✓ ✓ If the numbers cannot be converted (error = 1), give an error message to the user. Here are some sample outputs: Enter a number: 6 Your number is: 6.00 Process returned e (exe) Press any key to continue. Enter a number: 4.678 Your number is: 4.68 Process returned 0 (0x0) Press any key to continue. execution time: 9.563 S execution time: 5.820 s Enter a number: hello Error has been occurred due to inappropriate input! Process returned 0 (0x0) execution time: 3.126 s Press any key to continue. #include #include #define SIZE 250 float myAtof (char *string, char *error); int main() { } char string[SIZE]; float fnum1; char errorState=0; } // Array declaration. printf( Enter a number: ); gets (string); fnum1-myAtof(string, &errorState); if (errorState ==0) { printf( Your number is: %.2f , fnum1); }else if (errorState==1){ printf( Error has been occurred due to inappropriate input! ); } return 0; float myAtof (char* string, char* error) { //your code comes here!!! // Function to convert string into float. In this part of the assignment, you will use your own atof function that you implement in the task 1 to extend arithmetic operation evaluation (+,-,*/) to operate on floating-point numbers. You will get a character array from the user. The user will enter the operation in the form • 1.25 + 12 • 0.24 * 3 etc. The output will be 1.25 12.00 13.25. Do not use the functions of String library. Use gets() function to get the operation from the user. Notice that end of input is indicated by null character \0 Numbers will be printed with two-digit precision after decimal point. ✓ If the user enters an invalid operation, give a message. Here are some sample outputs: Enter arithmetic operation: 0.00 0.00 0.00 Process returned (exe) execution time: 14.202 s Press any key to continue. Enter arithmetic operation: 6-2 6.00 2.00 4.00 Process returned 0 (0x0) execution time: 3.713 s Press any key to continue. Enter arithmetic operation: 3.7/3 3.70 3.00 1.23 Process returned 0 (exe) Press any key to continue. Enter arithmetic operation: 5.3*2.1 5.30 2.10 11.13 Process returned e (exe) Press any key to continue. execution time : 5.604 s execution time : 6.372 s Enter arithmetic operation: 3.7 * 5 Error has been occurred due to inappropriate input! Process returned 0 (0x0) execution time: 10.354 s Press any key to continue. Enter arithmetic operation: 4+hello Error has been occurred due to inappropriate input! Process returned 0 (0x0) execution time: 7.720 s Press any key to continue. Process returned 0 (0x0) Press any key to continue. Enter arithmetic operation: 4/0 Cannot divided into 0. execution time: 4.016 s
Expert Answer:
Answer rating: 100% (QA)
The task requires implementing two features 1 A custom myAtof function that converts a string to a f... View the full answer
Related Book For
Auditing and Assurance services an integrated approach
ISBN: 978-0132575959
14th Edition
Authors: Alvin a. arens, Randal j. elder, Mark s. Beasley
Posted Date:
Students also viewed these electrical engineering questions
-
c language do with this skeleton please atof is a function in the C programming language that converts a string into a floating-point numerical representation. atof stands for ASCII to float. Task 1....
-
Please solve this problem using C language Hacker Industries has a number of employees. The company assigns each employee a numeric evaluation score and stores these scores in a list. A manager is...
-
Do you agree with Woods description? What advice about language use would you give to an ambitious woman making her way through a professional career in which men are in the majority?
-
?
-
The fiscal year for Hokkaido Company ends on May 31. Results for the year ended May 31, 20X1, included the following (in millions of Japanese yen except for number of shares outstanding): Cash and...
-
The mobile crane has weight W1 and center of gravity at G1; the boom has weight W2 and center of gravity at G2. Determine the smallest angle of tilt of the boom, without causing the crane to...
-
From 2008 to 2015, auto loan rates in the United States declined from around 8% to near historic lows of around 4%. At the same time, auto sales increased dramatically. How, if at all, does this...
-
Review the Comprehensive Annual Financial Report (CAFR) that you obtained. 1. How does the government classify its governmental expenditures, by function or by object? Are the classifications...
-
Find all complex roots of the following equations: (a) z + 64 = 0 (b) z5 +243 = 0 Write the result in the conventional form, i.e., as a sum of the real and imaginary parts. Show all details of work.
-
Hill-O-Beans Coffee Company blends four component beans into three final blends of coffee: one is sold to luxury hotels, another to restaurants, and the third to supermarkets for store label brands....
-
Common Stock - $1 par value; 200,000 shares authorized, 150,000 shares issued, 140,000 shares outstanding Convertible $2 preferred stock - $10 par value; 25,000 shares authorized, issued, and...
-
2.1 Draw the computation graph of function y = 1/sqrt(1+x^3) + x^0.5 at x = 3. Both the forward path and backward path should be calculated. 2.2 Implement a function to reverse transpose an arbitrary...
-
what are the consequences of the United States relying more on the market model or government model to solve poverty?
-
What are the types of economic systems, their characteristic, their advantages and their disadvantage.
-
Revere College predicts that in 6 years it will take $150,000 to attend the college for four years. Madison has a substantial amount of cash and wishes to invest a lump sum of money for her childs...
-
At 9% effective annual interest, what is the present worth of $125,000 that becomes available in eighteen years?
-
You pick a card at random, put it back, and then pick another card at random. 234 What is the probability of picking a 4 and then picking a 4 ? Write your answer as a fraction or whole number.
-
Outline a general process applicable to most control situations. Using this, explain how you would develop a system to control home delivery staff at a local pizza shop.
-
Explain how an engagement letter might affect an auditor's liability to clients under common law.
-
During the audit of the Merrill Manufacturing Company, Ralph Pyson, CPA, has become aware of four lawsuits against the client through discussions with the client, reading corporate minutes, and...
-
Explain why a proper cutoff of purchases and sales is heavily dependent on the physical inventory observation. What information should be obtained during the physical count to make sure that cutoff...
-
One difference between accounting for a governmental (not-for-profit) unit and a commercial (for-profit) enterprise is that a governmental unit should a. Not record depreciation expense in any of its...
-
Carson Citys general fund issued purchase orders of $630,000 to vendors for supplies. Which of the following entries should the city make to record this transaction? Debit Credit Q. ENCUMBRANCES...
-
Belle Valley incurred $100,000 of salaries and wages for the month ended March 31, 20X2. How should this be recorded on that date? c. Expenditures Salaries and Wages Debit Vouchers Payable Salaries...
Study smarter with the SolutionInn App