“atof” function:
In C++, the predefined function “atof” is used to convert a string value into a double-precision floating point value; it passes a string literal or character array as an argument and it converts the received value into a double type value; it takes only one parameter as an argument.
- If the argument value contains nonconvertible contents combined with the integer value then the values will be ignored while converting.
- In same way, the function will return “0” when the values can’t be able to convert into double data type.
Syntax:
Syntax for the “atof” function is as follows:
double atof (const char* n);
In the above statement,
- “double” represents the return type of the function.
- “atof” represents the name of the function.
- “const char*” represents the data type of the passing argument.
- “n” is a string variable which is required to be converted.
Example:
The example for the “atof” function is as follows:
//change the string literal to a double value.
double n = atof ("1258.11E-14 ");
In the above line, the string literal “1258.11E-14” is passed as an argument to “atof” and it returns the converted value that is “1.25811e-11”.
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Starting Out with C++: Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
- Write a single statement that prints a number at random from 3, 5, 7, 9, 11.arrow_forwardWrite two scnr.nextInt statements to get the input values into birthMonth and birthYear.Then write a statement to output the month, a slash and the year. End with newline.arrow_forwardWrite two scnr.nextInt statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a slash, and the year. End with newline.Ex: If the input is 1 2000, the output is:1/2000arrow_forward
- Write a statement to output the bottom plot. yVals2 = 0.5 * (abs(cos(2*pi*xVals)) - cos(2*pi*xVals));arrow_forwardThe following statement will evaluate to True: (5 > 6) AND (12 < 14) True Falsearrow_forwardLet s1 be a variable containing the string "utica". Which of the following expressions changes the value in s1 to "Utica"? Select one: a. 'U'+s1[1:] b. s1='U'+s1[1:] c. s1[0]='U' d. s1='U'+s1arrow_forward
- Please just state if the statement is true or false.arrow_forwardCreate an if-then statement that gives the value 0 to the variable b if the value of the variable an is less than 10 and else does nothing. In every other case, it should set the value of the variable b to 99.arrow_forwardWrite a switch statement that displays Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, if day is 0, 1, 2, 3, 4, 5, 6, respectively.arrow_forward
- Write a statement that converts the following string values to the decimaldata type using the decimal.Parse method. "9.05"arrow_forwardWhich of the following expressions will produce the shown string?arrow_forwardWhat is the value of each of this postfix expression? 3 2 ∗ 2 ↑ 5 3 − 8 4 / ∗ −arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage