## Library Function

**#include Directive**

The # include directive instructs the compiler to read and include another file in the current file. The compiler compiles the entire code. A header file may be included in one of two ways.

include <iostream.h>

or

include "iostream.h"

The header file in angle brackets means that file reside in standard include directory. The header file in double quotes means that file reside in current directory.

**LIBRARY FUNCTION**

C++ provides many built in functions that saves the programming time

**Mathematical Functions**

Some of the important mathematical functions in header file **math.h** are

Function |
Meaning |

sin(x) | Sine of an angle x (measured in radians) |

cos(x) | Cosine of an angle x (measured in radians) |

tan(x) | Tangent of an angle x (measured in radians) |

asin(x) | Sin-1 (x) where x (measured in radians) |

acos(x) | Cos-1 (x) where x (measured in radians) |

exp(x) | Exponential function of x (ex) |

log(x) | logarithm of x |

log 10(x) | Logarithm of number x to the base 10 |

sqrt(x) | Square root of x |

pow(x, y) | x raised to the power y |

abs(x) | Absolute value of integer number x |

fabs(x) | Absolute value of real number x |

**Character Functions**

All the character functions require **ctype.h** header file. The following table lists the function.

Function |
Meaning |

isalpha(c) | It returns True if C is an uppercase letter and False if c is lowercase. |

isdigit(c) | It returns True if c is a digit (0 through 9) otherwise False. |

isalnum(c) | It returns True if c is a digit from 0 through 9 or an alphabetic character (either uppercase or lowercase) otherwise False. |

islower(c) | It returns True if C is a lowercase letter otherwise False. |

isupper(c) | It returns True if C is an uppercase letter otherwise False. |

toupper(c) | It converts c to uppercase letter. |

tolower(c) | It converts c to lowercase letter. |

**String Functions
**The string functions are present in the

**string.h**header file. Some string functions are given below:

strlen(S) | It gives the no. of characters including spaces present in a string S. |

strcat(S1, S2) | It concatenates the string S2 onto the end of the string S1. The string S1 must have enough locations to hold S2. |

strcpy(S1, S2) | It copies character string S2 to string S1. The S1 must have enough storage locations to hold S2. |

strcmp((S1, S2)==0) strcmp((S1, S2)>0) strcmp((S1, S2) <0) |
It compares S1 and S2 and finds out whether S1 equal to S2, S1 greater than S2 or S1 less than S2. |

strcmpi((S1, S2)==0) strcmpi((S1, S2)>0) strcmpi((S1, S2) <0) |
It compares S1 and S2 ignoring case and finds out whether S1 equal to S2, S1 greater than S2 or S1 less than S2. |

strrev(s) | It converts a string s into its reverse |

strupr(s) | It converts a string s into upper case |

strlwr(s) | It converts a string s into lower case |

**Console I/O functions**

The following are the list of functions are in **stdio.h**

getchar() | It returns a single character from a standard input device (keyboard). It takes no parameter and the returned value is the input character. |

putchar() | It takes one argument, which is the character to be sent to output device. It also returns this character as a result. |

gets() | It gets a string terminated by a newline character from the standard input stream stdin. |

puts() | It takes a string which is to be sent to output device. |

** General purpose standard library functions**

The following are the list of functions are in **stdlib.h**

randomize() | It initializes / seeds the random number generator with a random number |

random(n) | It generates a random number between o to n-1 |

atoi(s) | It converts string s into a numerical representation. |

itoa(n) | It converts a number to a string |

**Some More Functions**

**The getch() and getche() functions**

The general for of the getch() and getche() is

ch=getche();

ch1=getch();

ch and ch1 are the variables of type character. They take no argument and require the **conio.h** header file. On execution, the cursor blinks, the user must type a character and press enter key. The value of the character returned from getche() is assigned to ch. The getche() fuction echoes the character to the screen. Another function, getch(), is similar to getche() but does not echo character to the screen.