Math function examples in C++ are programs that use the math library functions to perform mathematical calculations. The math library provides a wide range of mathematical functions that are useful in scientific and engineering applications, as well as in everyday programming. Some examples of math function programs in C++ include:
These are just a few examples of how math functions can be used in C++ programs. There are many more functions available in the math library, and they can be combined in various ways to perform complex calculations.
#include<iostream> #include<stdlib.h> #include<math.h> using namespace std; int main() { int z=-10; cout<<"Absolute value of z=-10 : "<<abs(z)<<endl; return 0; }To download raw file Click Here
Absolute value of z=-10 : 10
#include<iostream> #include<math.h> using namespace std; int main() { float x=-4.57; cout<<"\nAbsolute value of x=-4.57 is : "<<fabs(x)<<endl; return 0; }To download raw file Click Here
Absolute value of x=-4.57 is : 4.57
#include<iostream> #include<math.h> using namespace std; int main() { float y=12.3; cout<<"\nCeiling value of y=12.3 : "<<ceil(y)<<endl; return 0; }To download raw file Click Here
Ceiling value of y=12.3 : 13
#include<iostream> #include<math.h> using namespace std; int main() { float x=4.56; cout<<"Floor value of x=4.56 is : "<<floor(x)<<endl; return 0; }To download raw file Click Here
Floor value of x=4.56 is : 4
#include<iostream> #include<math.h> using namespace std; int main() { int x=3.0,y=4.0; cout<<"\nHypotenuse having other two sides as x=3.0 and"<<" y=4.0 : "<<hypot(x,y)<<endl; return 0; }To download raw file Click Here
Hypotenuse having other two sides as x=3.0 and y=4.0 : 5
#include<iostream> #include<math.h> using namespace std; int main() { float y=100.0; cout<<"\nLog value of y=100.0 is : "<<log(y)<<endl; return 0; }To download raw file Click Here
Log value of y=100.0 is : 4.60517
#include<iostream> #include<math.h> using namespace std; int main() { int x=3.0,y=4.0; cout<<"\nPower value: x^y=(3.0^4.0) : "<<pow(x, y)<<endl; return 0; }To download raw file Click Here
Power value: x^y=(3.0^4.0) : 81
#include <iostream> #include <math.h> using namespace std; int main() { double y=0.25; cout<<"Square root value of y=0.25 : "<<sqrt(y)<<endl; return 0; }To download raw file Click Here
Square root value of y=0.25 : 0.5
#include<iostream> #include<math.h> using namespace std; int main() { double x=2.3; cout<<"\nSine value of x=2.3 : "<<sin(x)<<endl; cout<<"\nCosine value of x=2.3 : "<<cos(x)<<endl; cout<<"\nTangent value of x=2.3 : "<<tan(x)<<endl; x=1.0; cout<<"\nArc Cosine value of x=1.0 : "<<acos(x)<<endl; cout<<"\nArc Sine value of x=1.0 : "<<asin(x)<<endl; cout<<"\nArc Tangent value of x=1.0 : "<<atan(x)<<endl; x=57.3; cout<<"\nHyperbolic Cosine of x=57.3 : "<<cosh(x)<<endl; cout<<"\nHyperbolic tangent of x=57.3 : "<<tanh(x)<<endl; return 0; }To download raw file Click Here
Sine value of x=2.3 : 0.745705 Cosine value of x=2.3 : -0.666276 Tangent value of x=2.3 : -1.11921 Arc Cosine value of x=1.0 : 0 Arc Sine value of x=1.0 : 1.5708Arc Tangent value of x=1.0 : 0.785398 Hyperbolic Cosine of x=57.3 : 3.83746e+24 Hyperbolic tangent of x=57.3 : 1
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions