C programming has numerous functions. These functions are used to operate on floats.
math.h
tan()
, cos()
, sin()
- these functions are standard trigonometric functions that all work in radius.
sqrt()
- this function is used to determine the square root of the given value.
pow(x,y)
- this function returns the value .
fabs()
- this function returns an absolute value.
log()
, exp()
- these functions provides a natural logarithm and a natural exponent.
log10()
- this functions denotes the base 10 logarithm.
stdlib.h
abs()
, labs()
-these functions return the value of an int
and a long
.
div(x,y)
- it returns the structure with the division and remainder of x/y
for int
and a long
.
Let’s see a example program of how the sqrt()
, pow()
, abs()
functions work:
#include<stdio.h>#include <math.h>#include<stdlib.h>int main(){printf("%f",sqrt(25));printf("%f",sqrt(7));printf("%f",pow(2,5));printf("%f",pow(3,2));printf("%d",abs(-12));return 0;}
Let’s see a program that illustrates the fabs()
function:
#include <stdio.h>#include <math.h>int main (){int h, s;h = 4321;s = -443;printf("The absolute value of %d is %lf\n", h, fabs(h));printf("The absolute value of %d is %lf\n", s, fabs(s));return(0);}