Built-in functions in C++

Library function:
  • C language provides built-in functions called library function.
  • The C standard library consists of a wide verity of header files which can be included in 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 returns 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 particular 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 a 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<iostream.h>
#include<conio.h>
#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
clrscr();
cout<<" The current date and time is : \n"<<ctime(&t));
cout<<" The sequre root of 25 value is : \n"<<sqrt(25));
cout<<" The log(5.6) value is : \n"<<log(5.6));
cout<<" The exp(12.0) value is : \n"<<exp(12.0));
cout<<" The power 4 of 2 is : \n"<<pow(4,2));
cout<<" The round of 5.6 value is : \n"<<ceil(5.6));
cout<<" The modulo of 7/3 value is : \n"<<fmod(7,3));
cout<<" sin(90) value is : \n"<< sin(90));
cout<<" cos(90) value is : \n"<<cos(90));
cout<<" tan(45) value is : \n"<< tan(45));
cout<<" The ASCII chacter w value is :  \n"<< toascii('w'));
cout<<" The lower value of chacter H is : \n"<<tolower('H'));
cout<<" The upper value of chacter e is : \n"<<toupper('e'));
getch();
}

Output:
Share:

No comments:

Post a Comment

Popular Posts

Search This Blog

Powered by Blogger.

Blog Archive

Service Support

Need our help to Learn or Post New Concepts Contact me

Blog Archive

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me