C Standard Library Function - DEEP CODER

Breaking

printf("Learn Deep Coding Here!!");

C Standard Library Function

Importance Of Library Functions: 

                       One of the most importance is that these libraries function make work
easy and also make program code short and understandable.It saves valuable time
effort and your code may not always be the most efficient.



Use Of Library Function To Find Square root

Suppose, you want to find the square root of a number.


You can always write your own piece of code to find square root but, this process
 is time consuming and it might not be the most efficient process to find square root.
However, in C programming you can find the square root by just using sqrt() function which is defined under header file "math.h".


#include <stdio.h>
#include <math.h>
int main()
{
   float num, root;
   printf("Enter a number: ");
   scanf("%f", &num);
   // Computes the square root of num and stores in root.
   root = sqrt(num);
   printf("Square root of %.2f = %.2f", num, root);
   return 0;
}

C library Function Under Different Header Files


C Header Files

<assert.h>                       Program assertion functions
<ctype.h>                      Character type functions
<locale.h>                       Localization functions
<math.h>                        Mathematics functions
<setjmp.h>                       Jump functions
<signal.h>                       Signal handling functions
<stdarg.h>                      Variable arguments handling functions
<stdio.h>                       Standard Input/Output functions
<stdlib.h>                             Standard Utility functions
<string.h>                       String handling functions
<time.h>                               Date time functions

No comments:

Post a Comment