Built-in Functions

Built-in functions are the functions that are provided by the standard library. These functions are readily available for use without the need for additional coding or defining them yourself. We just need to import the library in which they are written and call them.

Built-in Functions in stdio:

The "stdio" stands for standard input/output. This header file contain a large number of standard input and output functions that are used to get input from the input devices and also to print result on the output device. The commonly used functions of this header file and their description are given below.


The "getchar" Function:-

This function is used to get a single character from a standard input device i.e. from the keyboard during program execution. The key features of this function are: 1. When a character is entered it is displayed on the screen. 2. Enter key must be pressed to complete the input.
var = getchar();  //use of var is optional


The "putchar" Function:-

The putchar function is used to put single character on screen.
int putchar(int c);


The gets Function:-
The gets function is used to take input in string type variable.
gets(var_name); 


The puts Function:-

The puts function is used to print string type variable on screen.
puts(var_name); 

Built-in functions of string:

The "string.h" header file contains the functions that are used to process strings. The commonly used functions of this header file are given below.


The "strlen" Function:-

This function is used to find the number of characters in string. Is counts the total number of characters including spaces. Null characters are excluded.
int strlen(string);


The "strcmp" Function:-

This function is used to compare two strings. It compares first string with the second string character by character.
int strcmp(string1 , string2 );


The "strncmp" Function:-

This function is similar to the "strcmp" function but it compares specified number of characters of the two strings.
int strncmp (string1, string2, n);


The "strcpy" Function:-

It is used to copy the contents of one string variable including the null character (‘\0’).
strcpy(string1, string2);


The "strncpy" Function:-

It is similar to strcpy function but it is used to copy a specified number of characters from one string to another string variable.
strncpy(string1, srting2, n);


The "strcat" Function:-

It is used to append or combine the contents of one string to another string variable including the null character.
strcat(string1,string2);


The "strncat" Function:-

It is similar to strcat function but it is used to append a specified number of characters of one string to another string variable.
strncat(string1, string2, n);


Built-in functions in math.h:

The functions that are need to perform the mathematical calculations are defined in "math.h" header file.


The pow Function:-

It is used to calculate the exponential power of a given integer number.
pow(x , y);


The sqrt Function:-

It is used to calculate the square root of a given positive number.
sqrt(x);


The floor Function:-

It is used to round a given float value to the integer value. The given float value is converted into largest integer value that is not greater than the given float value.
floor(x);


The ceil Function:-

It is similar to the floor function but it returns the rounded integer value greater than the given float or double number.
ceil(x);


The fmod Function:-

It is used to calculate the remainder by dividing one floating point number by another floating point number.
fmod(x, y);


The cos Function:-

It is used to calculate the trigonometric cosine of a given angle. The angle is given in radius as a floating number.
cos(x);


The sin Function:-

It is used to calculate the trigonometric sine of a given floating number. The angle is given in radians as a floating number.
sin(x);


The tan Function:-

It is used to calculate the trigonometric tangent of a given floating number. The angle is given in radians as a floating number.
tan(x);


The log Function:-

It is used to calculate the natural logarithm (base e) of a given floating number.
log(x);


The log10 Function:-

It is used to calculate the logarithm (base 10) of a given floating number.
log10(x);