0% found this document useful (0 votes)
5 views27 pages

Additional Topic. Built in Libraries

The document outlines various built-in libraries in C++ for character, string, and mathematical functions. It details specific functions such as isalpha, isdigit, toupper, and tolower for character manipulation, as well as string functions like size, assign, append, and compare. Additionally, it covers mathematical functions including sqrt, pow, sin, and cos for performing calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views27 pages

Additional Topic. Built in Libraries

The document outlines various built-in libraries in C++ for character, string, and mathematical functions. It details specific functions such as isalpha, isdigit, toupper, and tolower for character manipulation, as well as string functions like size, assign, append, and compare. Additionally, it covers mathematical functions including sqrt, pow, sin, and cos for performing calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Built-in Libraries

CS 111 - Computer Programming


Pre-defined Character
Functions
Character Functions
• C++ provides several pre-defined functions for character manipulation.

• These functions allow you to perform various operations on characters,


such as checking if a character is alphabetic or numeric, converting
characters to uppercase or lowercase, and more.
isalpha
• The isalpha function in C++ checks whether a given character is an
alphabetic character (A-Z or a-z). It returns a non-zero value if the character
is alphabetic, otherwise it returns zero.
isdigit
• The isdigit function in C++ checks whether a given character is a digit (0-9).
It returns a non-zero value if the character is a digit, otherwise it returns
zero.
toupper and tolower
• The toupper and tolower functions in C++ convert a character to uppercase
and lowercase, respectively. They return the converted character.
Pre-defined String
Functions
String Functions
• C++ programming provides a set of standard string functions that allow
you to perform various operations on strings.

• These functions simplify string manipulation, searching, and other


common tasks.
size
• The size function is used to determine the length of a string. It returns the
number of characters in the string.
assign
• The assign function is used to copy one string to another. It copies the
contents of the source string to the destination string.
append
• The append function is used to concatenate (append) two strings. It
appends the contents of the source string to the end of the destination
string, modifying the destination string.
compare
• The compare function is used to compare two strings. It returns an integer
value that indicates the relationship between the two strings. If the strings
are equal, it returns 0. If the first string is less than the second string, it
returns a negative value. If the first string is greater than the second string,
it returns a positive value.
Pre-defined Math
Functions
Math Functions
• C++ programming provides a math library that contains a set of pre-
defined mathematical functions.

• These functions are included in the <cmath> header file and allow you to
perform various mathematical operations, such as calculating square
roots, raising numbers to a power, and evaluating trigonometric functions.
sqrt
• The sqrt function is used to calculate the square root of a number. It takes
a single argument and returns the square root as a double value.
pow
• The pow function is used to raise a number to a power. It takes two
arguments: the base number and the exponent. It returns the result as a
double value.
sin and cos
• The sin and cos functions are used to calculate the sine and cosine of an
angle, respectively. These functions take the angle in radians as an
argument and return the corresponding sine or cosine value as a double
value.

You might also like