Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 12.3, Problem 12.11CP
Program Plan Intro
“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”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a statement that will convert the Base 3 string 21201 to a numeric integerand store the result in the variable num
Prompt the user to enter a string and then check
whether that string starts with "U301-" or not. If
the string starts with "U301-" then print "Valid
Entry.", otherwise print "Invalid Entry.".
Write a single scanf statement that reads user-entered time (three integers) and discards the user-entered characters between the numbers, in order, for hour (hh), minute (mm), and second (ss). For example, the user may enter the time as 12:23:21 or 12 23 21 or 12, 23, 21.
Chapter 12 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 12.2 - Write a short description of each of the following...Ch. 12.2 - What will the following program segment display?...Ch. 12.2 - Prob. 12.3CPCh. 12.2 - Prob. 12.4CPCh. 12.2 - Write code that uses the cin.get1ine function read...Ch. 12.2 - Indicate whether the following strcmp function...Ch. 12.2 - Prob. 12.7CPCh. 12.3 - Write a short description of each of the following...Ch. 12.3 - Write a statement that will convert the C-string...Ch. 12.3 - Prob. 12.10CP
Ch. 12.3 - Prob. 12.11CPCh. 12.3 - Prob. 12.12CPCh. 12.4 - What is the output of the following program?...Ch. 12 - A(n)___________is represented in memory as an...Ch. 12 - The____________ statement is required before the...Ch. 12 - A(n)____________is written in your program as a...Ch. 12 - Prob. 4RQECh. 12 - The______________ is used to mark the end of a...Ch. 12 - Prob. 6RQECh. 12 - Prob. 7RQECh. 12 - Prob. 8RQECh. 12 - Prob. 9RQECh. 12 - Prob. 10RQECh. 12 - Prob. 11RQECh. 12 - Prob. 12RQECh. 12 - Prob. 13RQECh. 12 - Prob. 14RQECh. 12 - Prob. 15RQECh. 12 - Prob. 16RQECh. 12 - Prob. 17RQECh. 12 - Prob. 18RQECh. 12 - Write a function whose prototype is char...Ch. 12 - #inc1ude iostream using namespace std; int main()...Ch. 12 - #include iostream using namespace std; int main()...Ch. 12 - #include iostream using namespace std; int main()...Ch. 12 - #inc1ude iostream #inc1ude string using namespace...Ch. 12 - #inc1ude iostream #inc1ude cstring using namespace...Ch. 12 - #inc1ude iostream using namespace std; int main()...Ch. 12 - #inc1ude iostream #inc1ude string using namespace...Ch. 12 - #include iostream #inc1ude cstring using namespace...Ch. 12 - #include iostre4m #inc1ude cstring using namespace...Ch. 12 - Each of the following programs or program segments...Ch. 12 - Soft Skills 30. You are a member of a...Ch. 12 - Prob. 1PCCh. 12 - Prob. 2PCCh. 12 - Prob. 3PCCh. 12 - Prob. 4PCCh. 12 - Name Arranger Write a program that asks for the...Ch. 12 - Prob. 6PCCh. 12 - Prob. 7PCCh. 12 - Prob. 8PCCh. 12 - Prob. 9PCCh. 12 - Password Verifier Imagine you are developing a...Ch. 12 - Prob. 11PCCh. 12 - Check Writer Write a program that displays a...Ch. 12 - Prob. 13PCCh. 12 - Dollar Amount Formatter Modify Program 12-13 by...Ch. 12 - Word Separator Write a program that accepts as...Ch. 12 - Prob. 16PCCh. 12 - I before e except after c A friend of yours who is...Ch. 12 - User Name Write a program that queries its...Ch. 12 - String Splitter Write a function vectorstring...Ch. 12 - Palindromic Numbers A palindromic number is a...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a statement that will convert the C-string “100000” to a long and store the result in the variable num.arrow_forwardWhich expression for XXX causes the code to output the strings in alphabetical order? (Assume the strings are lowercase) if (XXX) { printf("%s %s\n",firstString, secondString); } else { printf("%s %s\n",secondString, firstString); }arrow_forwardWrite a statement that converts PI to an angle in degrees and assigns the result to a variable.arrow_forward
- 3a - Write a regular expression that finds all strings starting with a number between 0 and 299 inclusively, followed by an x, followed by any combination of zero or more x and y, and ends with y. Examples of accepted strings: 299xxy, 4xyy, 156xy, 23xxxyyy, 23xxyxyy, 0xxyy Examples of rejected strings: 300xy, 400yx, 305yyyx, 444yxyxy, 002xy 3b - One way of implementing a specific regular expression as a computer program is to convert the regular expression to its equivalent Finite Automaton. Draw an NFA or DFA for your regular expression in part 3a.arrow_forward(this question is part 2 of 3 in a long problem) JavaScript Commands Create the nameSearch variable equal to the value entered in the nameSearch input box. Users can search for names in three ways: Matching an employee's last name if it contains the text string specified in nameSearch Matching an employee's last name if it begins with the nameSearch text string Matching an employee's last name only if it exactly matches the nameSearch text string. Richard has supplied you with code to add the selectedValue() method to the prototype of the HTMLSelectElement object class in order to return the value of the selected option in any selection list. Apply the selectedValue() method to the nameSearchType selection list to return the option selected by the user, storing the value in the nameSearchType variable. Create a switch-case structure for the following possible values of the nameSearchType variable: If nameSearchType equals "contains", use the new RegExp() constructor to create a…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_forward
- |Q3/ Using switch Write a Program to read the correct variable(x) then calculate and print the value of (y) that is Зx-7 if x=-3 [ 5x² if x= 2 or 3 Y= x-4x3 if x= -4 or 4arrow_forwardWrite a statement that produces a random number between 1 and 100 and stores it in the variable luckyNumber.arrow_forwardFor which of the following statements will the variable s contain a string data type after it is executed?arrow_forward
- Write a code that asks the user to enter several numbers that are a multiple of 5. If the user enters a value that is not a multiple of 5 it should print a message and prompt the user to enter a new number. The user can stop the process by inputting the string *done*. At the end, print the total number of values entered that are a multiple of 5.arrow_forwardDeclare a Boolean variable named isValidPasswd. Use isValidPasswd to output "Valid" if checkStr contains at least 4 letters and checkStr's length is greater than 7, and "Invalid" otherwise. Ex: If the input is 58m6SF7w, then the output is: Valid Ex: If the input is NKXwLD2, then the output is: Invalid Note: isalpha() returns true if a character is alphabetic, and false otherwise. Ex: isalpha('a') returns true. isalpha('8') returns false.arrow_forwardExtend to cast the double to an integer, and output that integer. Enter integer: 99 Enter double: 3.77 Enter character: z Enter string: Howdy 99 3.77 z Howdy Howdy z 3.77 99 3.77 cast to an integer is 3arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Algebraic Expressions – Algebra Basics; Author: TabletClass Math;https://www.youtube.com/watch?v=U-7nq7OG18s;License: Standard YouTube License, CC-BY
Python Tutorial for Beginners 3 - Basic Math, Mathematical Operators and Python Expressions; Author: ProgrammingKnowledge;https://www.youtube.com/watch?v=Os4gZUI1ZlM;License: Standard Youtube License