a)
Explanation of Solution
“atoi” function:
In C++, the predefined function “atoi” is used to convert a string value into an integer value; it passes a string literal or character array as an argument and it converts the received value into an integer 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:
The syntax for the “atoi” function is as follows:
int atoi (const char* n);
In the above statement,
- “int” represents the return type of the function...
b)
Explanation of Solution
“atol” function:
In C++, the predefined function “atol” is used to convert a string value into a long integer value; it passes a string literal or character array as an argument and it converts the received value into a long integer 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 “atol” function is as follows:
long int atol (const char* n);
In the above statement,
- “long int” represents the return type of the function...
c)
Explanation of Solution
“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...
d)
Explanation of Solution
“itoa” function:
In C++, the predefined function “atof” is used to convert an integer value into a string literal; it contains three parameters to refer the integer to convert, pointer character to store the result, and base number to convert.
Note: It is a deprecated item in C++; so many C++ compilers are not supporting this function.
Syntax:
The syntax for the “itoa” function is as follows:
char* itoa ( int n, char* s, int base);
In the above statement,
- “char*” represents the return type of the function.
- The first parameter “int n” represents the number to be converted...
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Starting Out with C++: Early Objects
- 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