A library is a collection of programs and functions which can be used by other programs. Like all other high-level languages, C++ provides function libraries containing built-In functions. These standard functions are extremely useful to the programmers. The advantages of library functions are listed below:

  • Reusability of code : The program development activity requires three major activities: coding, testing and debugging. If a function is developed previously, then it is available as a standard library function and the effort of redevelopment can be avoided.
  • Faster development : Since many useful functions are available to the programmer, the program development process becomes faster and the productivity increases.
  • Easier software maintenance : Since a function available in the library is shared by other users and programmers, the changes or modification in the function can be done at a library level. Thus, the software maintenance becomes easier.

List of Standard Library Functions

1. isalum()

This function has a prototype in ctype.h header file. The argument to this function is a character represented as an int. It performs a test "is the character alphanumeric?". An alphanumeric character is a letter of either case or a digit. The function isalnum() returns a non-zero value if the character is alphanumeric and zero otherwise.

Example:

2. isdigit()

This function has a prototype in ctype.h header file. The argument to this function is also a character represented as int. This function performs the test "is the character a digit?". It returns a non-zero value if the character is a digit and a non-zero value otherwise.

Example:

3. isalpha()

This function is exactly similar to function isdigit(), in the sense that it performs the test "is the character alphabetic?". It returns a non-zero value if the character is a letter of either case and a zero value otherwise.

Example:

4. islower()

This function is also similar to the function given above. It performs the test "is the character a lower case letter?". It returns a non-zero value for condition being true and a zero value for false.

Example:

5. isupper()

The action of this function is exactly same as islower() except that it performs the test "is the character a upper case letter?". It returns a non-zero value for condition being true and zero for false.

Example:

6. tolower()

It is a case conversion function in the sense that it converts a character to its lower case value. If the character is an upper case letter (A to Z) then it is converted to its lower case value. All other are left unchanged. The prototype of this function is also contained in ctype.h header file.

Example:

7. toupper()

It is a case conversion function. It converts a lower case character to its upper case value. The action is exactly similar to function tolower().

Example:

8. strcpy()

This function copies one string to another. The function prototype of this function is contained in string.h header file. The general form of this function call is given below:

strcpy( destination, source)

It copies the source string to destination string. The copying action stops after the null character '' has been moved from source to destination.

Example:

9. strcat()

The prototype of this function is also contained in header file string.h. It appends a source string to the end of destination so that the length of the resulting string is equal to total of both the strings.

Example:

10. strlen()

This is also a string.h function. The argument to this function is a string and calculates its length i.e. it returns the number of characters in the string except the null character ''.

Example:

11. strcmp()

This is also a string.h function. It compares two strings s1 and s2. The comparison begins with the first character of both strings and continues with subsequent character until the end of the strings is reached or the compared characters differ from each other.

strcmp() returns a value less than zero if s1<s2, otherwise zero if s1 = s2. It returns a value more than zero if s1>s2.

Example:

12. abs()

This function has a prototype in math.h header file. The argument to this function is an integer. It calculates the absolute value of the integer

Example:

13. fabs()

This is also a math.h function. The argument to this function is a value of type float or double. It returns the absolute value of floating point number.

Example:

14. frexp()

This is a math.h function. The argument to this function is a double. It splits the number into mantissa and exponent.

Example:

15. fmod()

This function is in the math.h file. It returns the floating point remainder of the expression x/y i.e. in simple words, the portion to the right of the decimal part is returned. The x and y are of type double and the value returned is also of type double. However, the sign of the returned value is same as that of x.

Example:

16. log()

This is a function that takes an argument of type double and returns the natural logarithm of the argument. This function is in the math.h file.

Example:

17. log10()

This function takes an argument of type double and returns the logarithm to the base 10 of the argument

Example:

18. pow()

This function takes two arguments, a and b, of type double and returns a b.

Example:

19. sqrt()

This function takes one argument of type double and returns a non negative square root of the argument.

Example:

20. sin()

This function takes an angle as its argument of type double and returns the sine of the angle.

Note: angle must be in radians.

Example:

21. cos()

This function takes an angle as its argument of type double and returns the cosine of the angle.

Note: angle must be in radians.

Example: