Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

C++ Functions

Uploaded by

Aldrin Rogen
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

C++ Functions

Uploaded by

Aldrin Rogen
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<cctype> Header File

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

<cstring> header file

No Function Arguments Description


1 Strcpy( ) s1, s2 Copies string s2 into string s1
2 strcat( ) s1,s2 Appends or concatenates string s2 to the end of string s1
3 strlen( ) s1 Returns length of string s1
Returns 0: s1 and s2 are same
4 strcmp( ) s1,s2
<0:s1
Returns a pointer to first occurrence of character ch in string s1and the
5 strchr( ) s1,ch
string from there onwards
6 strstr( ) s1,s2 Returns first occurrence of string s2 in string s1

You might also like