Library functions in C - C-Tutorial

Latest

Friday, 11 November 2016

Library functions in C

Library functions

Functions that are predefined by the compiler are known as library functions. 

Ex:                          scanf(), printf(), getch(), getche(), etc.,

For all the library functions, definitions and necessary information is available in header files.  Some of the important header files are:

            stdio.h             -           Standard Input and Output header file
            conio.h            -           Console Input and Output header file
            stdlib.h            -           Standard library header file

            ctype.h                        -           Character type header file

            math.h             -           Mathematical header file

ctype.h                       -           Character type header file

            ctype.h header file provides several library functions used for character testing and conversions.

1. islower():                            Syntax:            islower(ch)
Function determines whether the given argument is in lowercase or not.  If it is in lowercase, then returns a non-zero value that represents TRUE; otherwise, it returns ‘0’ that represents FALSE.

2. isupper():                            Syntax:            isupper(ch)
Function determines whether the given argument is in uppercase or not.  If it is in uppercase, then returns a non-zero value that represents TRUE; otherwise, it returns ‘0’ that represents FALSE.

3. tolower():                            Syntax:            tolower(ch)
            Function converts the given argument from upper case to lower case.

4. toupper():                           Syntax:            toupper(ch)
            Function converts the given argument from lower case to upper case.

math.h                        -           Mathematical header file

        math.h header file provides several library functions used for mathematical operations.


1. sin():                        Syntax:            sin(d)

            Where, d is a double type argument.
            Function receives a double type argument and returns the sine value as double.
                        Ex:       printf(“%lf”, sin(45));

2. cos():                       Syntax:            cos(d)
            Function receives a double type argument and returns the cosine value as double.
                        Ex:       printf(“%lf”, cos(45));

3. tan():                       Syntax:            tan(d)
            Function receives a double type argument and returns the tangent value as double.
                        Ex:       printf(“%lf”, tan(45));

4. log():                       Syntax:            log(d)
            Function receives a double type argument and returns the natural logarithm (base e) value as double.
                        Ex:       printf(“%lf”, log(10));

5. sqrt():                      Syntax:            sqrt(d)
            Function receives a double type argument and returns the square root value as double.
                        Ex:       printf(“%lf”, sqrt(36));

6. pow():                     Syntax:            pow(d1, d2)
            Function receives two double type arguments and returns the d1 raised to the d2 power value as double.

                        Ex:       printf(“%lf”, pow(3,4));

No comments:

Post a Comment