Mathematical Functions in C++

C++ has a built-in library of mathematical functions defined in cmath. Write a C++ program to show all the required built-in functions. C++ program includes functions to find square root of a number, sine value of a number, cosine value etc.

#define PI 3.1424
using namespace std;
int main(){
	cout<<"Math Functions : "<<endl;
	cout<<"Square Root funtion : \t"<<sqrt(2)<<endl;
	cout<<"Sine Function : \t"<<sin(30*PI/180)<<endl;
	cout<<"Cos Function : \t\t"<<cos(30*PI/180)<<endl;
	cout<<"Tan Function : \t\t"<<tan(30*PI/180)<<endl;
	cout<<"Inverse Sine Function : "<<asin(0.5)<<endl;
	cout<<"Inverse Cos Function : \t"<<acos(0.5)<<endl;
	cout<<"Inverse Tan Function : \t"<<atan(0.5)<<endl;
	cout<<"Exponential Function : \t"<<exp(2)<<endl;
	cout<<"Power Function : \t"<<pow(2,5)<<endl;
	cout<<"Absolute Function : \t"<<fabs(-12.32)<<endl;
	cout<<"Log Function : \t\t"<<log(25)<<endl;
	cout<<"Log base 10 Function : \t"<<log10(25)<<endl;
	cout<<"Ceil Function : \t"<<ceil(10.12)<<endl;
	cout<<"Floor Function : \t"<<floor(12.20)<<endl;
	return 0;
output of above program. mathematical functions
output of above program. mathematical functions

Leave a Reply