C++ Arithmetical Function
C function where are
used to perform mathematical operations
program are called arithmetical function.
This library are inbuilt in arithmetical function in c languge.
“math.h” and “stdlib.h”
header files support all the arithmetical function in c language.
List
of arithmetical function given below:
1.pow()
2.sin()
3.sqrt()
4.log()
Fig: C++ Arithmetical Function
1.pow()
This is used to find
power of given number.
Program
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n,j;
cout<<“Input two
number”;
cin>>i>>j;
n=pow(I,j);
cout<<n;
getch();
}
Output:
Input two value
5
3
125
2.sin()
This function is used
to calculate sine value.
Program
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n;
cout<<“Input number”;
cin>>i;
n=pow(I);
cout<<n;
getch();
}
Output:
Input value
90
0
3.sqrt()
This f unction is used
to find the square root of the argument
passed to this function.
Program
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n;
cout<<“Input number”;
cin>>i;
n=sqrt(I);
cout<<n;
getch();
}
Output:
Input value
25
5
4.log()
This function is used
to calculate the natural logarithm.
Program
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
double n,x;
x=72.325;
n=log(x);
cout<<n;
cout<<x;
getch();
}
Ouput:
72.325
4.28117
No comments:
Post a Comment