Concept explainers
“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”.
Trending nowThis is a popular solution!
Chapter 10 Solutions
MyProgrammingLab - For Gaddis: Starting Out with C++ From Control Structures through Objects
- Password modifier This program is: python Many user-created passwords are simple and easy to guess. Write a program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string. i becomes ! a becomes @ m becomes M B becomes 8 o becomes . Ex: If the input is: mypassword the output is: Myp@ssw.rdq*s Hint: Python strings are immutable, but support string concatenation. Store and build the stronger password in the given password variable.arrow_forward#include <stdio.h> struct dna { int number; char text; char stringvalue[30]; }; int main() { struct dna dnavalue[5]; int i; for(i=0; i<4; i++) { printf("Sample %d\n",i+1); printf("Enter Number:\n"); scanf("%d", &dnavalue[i].number); printf("Enter Text :\n"); scanf("%c",&dnavalue[i].text); printf("Enter String :\n"); scanf("%s",dnavalue[i].stringvalue); } printf("Sample DNA Number Text String\n"); for(i=0; i<4; i++) { printf("%d\t\t", i+1); printf("%d\t\t", dnavalue[i].number); printf("%c\t\t", dnavalue[i].text); printf("%s", dnavalue[i].stringvalue); printf("\n"); } return 0; } Write comments on every line of this program explaining what's happening brieflyarrow_forward- **********DO NOT USE SOLUTIONS THAT USE C++ STRING OBJECTS!!! THIS MUST USE C-STRINGS (NULL-TERMINATED ARRAYS OF CHARS)!!!****** 4. This function returns the index in string s where the substring can first be found. For example if s is “Skyscraper” and substring is “ysc” the function would return 2. It should return -1 if the substring does not appear in the string. int findSubstring(char *s, char substring[]) 5. This function returns true if the argument string is a palindrome. It returns false if it is not. A palindrome is a string that is spelled the same as its reverse. For example “abba” is a palindrome. So is “hannah”, “abc cba”, and “radar”. bool isPalindrome(char *s) Note: do not get confused by white space characters. They should not get any special treatment. “abc ba” is not a palindrome. It is not identical to its reverse. 6. Extra Credit, up to 10 extra points. This function should reverse the words in a string. A word can be considered to be any characters, including…arrow_forward
- Please help me with this using java. Create a selection sort java code Please also comment the codearrow_forwardTrue or FalseWhen you call a string object’s Split method, the method divides the string into two substrings and returns them as an array of strings.arrow_forward#include <iostream> #include <string> #include <iomanip> using namespace std; void display(char ans); void display(int n); double calcPrice(double hour, int n) { double total; cout << "Total for " << hour << " hour(s): RM"; hour=hour/3; switch (n) { case 1: total=hour*6; cout << setprecision(4) << "" << total << endl; break; case 2: total=hour*5; cout << setprecision(4) << "" << total << endl; break; case 3: total=hour*7; cout << setprecision(4) << "" << total << endl; break; } return total; } struct Car { string car1; string car2; string car3; }; int main() { string name, ic, telNo; char ans, choice; int age, n; double hour; cout << "*** WELCOME TO CAR RENTAL SYSTEM ***" << endl << endl; Car types; types.car1 = "Sedan: Honda City, Honda Civic, Perodua Bezza"; types.car2 = "Hatchback: Perodua Axia, Proton Iriz, Perodua Myvi"; types.car3 = "SUV: Honda…arrow_forward
- #include <iostream> #include <string> #include <iomanip> using namespace std; void display(char ans); void display(int n); double calcPrice(double hour, int n) { double total; cout << "Total for " << hour << " hour(s): RM"; hour=hour/3; switch (n) { case 1: total=hour*6; cout << setprecision(4) << "" << total << endl; break; case 2: total=hour*5; cout << setprecision(4) << "" << total << endl; break; case 3: total=hour*7; cout << setprecision(4) << "" << total << endl; break; } return total; } struct Car { string car1; string car2; string car3; }; int main() { string name, ic, telNo; char ans, choice; int age, n; double hour; cout << "*** WELCOME TO CAR RENTAL SYSTEM ***" << endl << endl; Car types; types.car1 = "Sedan: Honda City, Honda Civic, Perodua Bezza"; types.car2 = "Hatchback: Perodua Axia, Proton Iriz, Perodua Myvi"; types.car3 = "SUV: Honda…arrow_forwardC++ Write a program that first asks the user to enter a string and then asks the user to enter a character. The program should display the number of times the character appears in the string. Use the function Count_char(). A function Count_char() that has two arguments. The first argument is an array and the second argument is a character. The function returns an integer.arrow_forwardProgramming language is C : (please write with more comments ..thank you) 1- Write a program to accept a string and count the number of vowels present in this string. 2- Write a program to find the largest and smallest element in Array.arrow_forward
- (Python) To cast a String, called data, to a integar, you use which of the following: int(data) data.int() Integer(data) new int(data)arrow_forwardSum of Numbers in a String Create an application that lets the user enter a string containing series of numbers separated by commas. Here is an example of valid input: 7,9,10,2,18,6 The program should calculate and display the sum of all the numbers.arrow_forwardCreat a class reversit and Write a function called reversit () that reverses a C-string (an array of char). Use a forloop that swaps the first and last characters, then the second and next-to-last characters, and so on. The string should be passed to reversit () as an argument. Write a program to exercise reversit (). The program should get a string from the user, call reversit (), and print out the result.by using c++arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education