The <math.h> header file contains various methods
for performing mathematical operations such as sqrt(), pow(), ceil(), floor() etc.
They are
Where n is the number.
1)ceil(number)
It returns the smallest integer value not less
than the number specified as an argument
Example:
ceil(2.2536); //output 3
ceil(-2.2536); //output -2
2)floor(number)
It returns the largest
integer value not greater than a number specified as an argument.
Example:
floor (2.2536); //output
2
floor (-2.2536); //output
–3
3)abs(number)
It returns the absolute
value of a number.
Example:
abs (6); //output
6
abs (-6); //output
6
4)sqrt(n)
This function returns the non-negative square root of n
This function returns the non-negative square root of n
Example:
Select
sqrt(49) // output is 7
5)pow(base,
exponent)
These two functions return the value of X
raised to the power of Y.
Example:
Select
pow (3, 2); // output is 9(3*3)
Select
pow (2, 4); // output is 16(2*2*2*2)
Example:
#include<stdio.h>
#include <math.h>
int main(){
printf("\n%f",ceil(4.6));
printf("\n%f",ceil(4.3));
printf("\n%f",floor(3.6));
printf("\n%f",floor(3.2));
printf("\n%f",sqrt(64));
printf("\n%f",sqrt(7));
printf("\n%f",pow(2,4));
printf("\n%f",pow(3,3));
printf("\n%d",abs(-17));
return 0;
}
Output:
5.000000
5.000000
3.000000
3.000000
8.000000
2.645751
16.000000
27.000000
17
You don't realize how quickly technology is changing. Data science is highly technical and is therefore in high demand. A career in data science will open up many lucrative job opportunities. So, if you have been wanting to start your career in Data Science, now is the best time to enroll in a data science program with one of the best data science training institute in noida.
ReplyDelete