C++ Functions
C++ Functions
This header contains function prototypes that are mainly used for converting the character to
upper/lower case or to check if a character is a digit etc.
Function prototypes included in <cctype> header are listed as below:
Function Description
toupper(ch) Takes in character ‘ch’ as an argument and returns the uppercase equivalent of ch
if it's present otherwise returns ch.
tolower(ch) Takes in character ‘ch’ as an argument and returns the lowercase equivalent of ch
if it's present otherwise returns ch.
isalpha(ch) Returns non-zero if ch is alphabet otherwise 0.
isalnum(ch) Returns non-zero if ch is alphanumeric (alphabet or number) otherwise 0.
isupper(ch) Returns non-zero value if ch is uppercase otherwise 0.
isdigit(ch) Returns non-zero value if ch is a number otherwise 0.
islower() Returns non-zero value if ch is lowercase otherwise 0.
stdlib> Header
We also have another header <stdlib> that includes various useful library functions that are used
extensively in C++ programming.
We have listed some of the popular functions in <stdlib> below:
Function Description
abs(x) Returns absolute value of an integral argument x
atof(const char* str) Converts string to double; returns double
atoi(const char* str) Converts string to int; returns an int
atol(const char* str) Converts string to long int; returns a long int
atoll(const char* str) Converts string to long long int; returns a long long int
<cmath> Header
This header contains various function prototypes related to mathematical functions. Some of the
prototypes that are used extensively are listed here.
Function Description
Accepts any non-negative numeric parameter x and returns the square root of
sqrt(x)
this number x
Raises the ‘base’ value to the power specified by the exponent. Returns
pow(base,exponent)
base^exponent.
Takes any number (positive, negative or zero) as a parameter and returns
exp(x)
exponential (Euler’s number) e raised to the given parameter
fabs(x) Returns absolute value of an argument.
log(x) Returns the natural logarithm (to the base e) of value x
log 10(x) Return the logarithm (to the base 10) of value x
Function Description
sin(x) Returns sine of the angle x (in radians)
cos(x) Returns cosine of angle x (in radians)
tan(x) Returns tangent of angle x (in radians)
asin(x) Returns inverse sine (in radians) of number x
acos(x) Returns inverse cosine (in radians) of number x
atan(x) Returns inverse tangent (in radians) of number x
le