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 main 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.
The "putchar" Function
The putchar function is used to put single character on screen.
The gets Function
The gets function is used to take input in string type variable.
The puts Function
The puts function is used to print string type variable on screen.
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 length of the string. Is counts the total number of characters including spaces. Null characters are excluded.
The "strcmp" Function
This function is used to compare two strings. It compares first string with the second string character by character.
The "strncmp" Function
This function is similar to the "strcmp" function but it compares specified number of characters of the two strings.
The "strcpy" Function
It is used to copy the contents of one string variable including the null character (‘\0’).
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.
The "strcat" Function
It is used to append or combine the contents of one string to another string variable including the null character.
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.
Built-in functions in math.h
The functions that are needed 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.
The sqrt Function
It is used to calculate the square root of a given positive number.
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.
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.
The fmod Function
It is used to calculate the remainder by dividing one floating point number by another floating point number.
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.
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.
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.
The log Function
It is used to calculate the natural logarithm (base e) of a given floating number.
The log10 Function
It is used to calculate the logarithm (base 10) of a given floating number.
Practice Exercises
Complete these exercises to reinforce your learning and earn XP