Pre-defined function

Library function:
  • C language provides built-in functions called library function.
  • The C standard library consists of wide verity of header files which can be included into a programmer’s project with a single directive.
  • Each header file contains one or more function declarations, data type definition, and macros.
  • The following library functions are,
1. sqrt(x):
This function evaluates the square root of ‘x’. Note that the argument must be non-negative.
Example: sqrt(25)
                Here the square root of 25 evaluated as 5.
2. log(x):
Where the argument ‘x’ must be real. Here loge x is evaluated.
Example:   log(7.5-x*y) this evaluate loge(7.5-xy)
3. exp(x):
This function evaluates ex. The argument must be of real quantity.
Example:   exp(7.5) this evaluate e7.5
4. pow(a,b):
Where the arguments ‘a’ and ‘b’ are maybe integer or float values.
This evaluates the value of ab.
Example:   pow(4,2) this evaluate (4)2.
5. ceil(x):
It is used to rounding x to the next integer value.
Example.    Ceil(5.6) evaluates 6
6. fmod(x,y):
It reterurn the remainder of x/y.
Example:   fmod(7,3) evaluates 1, because, when 7 is divided by 3 the remainder is 1.
7. sin(x):
This evaluates the trigonometric sine value.
Example:   sin(30) evaluate 0.5
8. cos(x):
This evaluates the trigonometric cosine value.
Example:    cos(30) evaluate 0.75
9. tan(x):
This evaluate the trigonometric tangent(  )value.
Example:    tan(30) evaluate 0.577
10. toascii(x):
Returns the integer value for the articular character.
Example:    toascii(a)     evaluates 97
11. tolower(x):
It is used to convert the character capital letter into a small letter.
Example:    tolower(‘Z’) evaluates z
12. toupper(x):
It is used to convert the character small letter into capital letter.
Example:    toupper(‘z’) evaluates Z.
13. ctime(t):
It is used to show the current time in your system.
Using #include<time.h> header file and time_t datatype.       
Example program for library function:

#include<math.h>//all mathematic calculations
#include<ctype.h>//to find ascii value
#include<time.h>//To display time
void main()
          time_t t; //time data type
          time(&t);//calling current time
printf(" The current date and time is : %s\n",ctime(&t));
printf(" The sequre root of 25 value is : %lf\n",sqrt(25));
printf(" The log(5.6) value is : %lf\n",log(5.6));
printf(" The exp(12.0) value is : %lf\n",exp(12.0));
printf(" The power 4 of 2 is : %lf \n",pow(4,2));
printf(" The round of 5.6 value is : %lf \n",ceil(5.6));
printf(" The modulo of 7/3 value is :%lf \n",fmod(7,3));
printf(" sin(90) value is : %lf\n", sin(90));
printf(" cos(90) value is : %lf\n", cos(90));
printf(" tan(45) value is : %lf\n", tan(45));
printf(" The ASCII chacter w value is : %d \n", toascii('w'));
printf(" The lower value of chacter H is : %c\n",tolower('H'));
printf(" The upper value of chacter e is : %c\n",toupper('e'));


No comments:

Post a Comment

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me