standard Math library Functions
:
#include<stdio.h>
// input output standard functions are defined in this
#include<math.h
>
// all standard math functions are defined
#include<stdlib.h>
// here used only for rand() function
void main()
{
int ab,random;
// variable declarations
double cel,cosine,floatabs,flo,logbase_e,logbase_10,power,expo,sq_root,ncel,nflo;
ab=abs(-8);
// gives absolute value of integer argument
cel=ceil(45.0001);
// Returns the smallest integer value greater than or equal to x
ncel=ceil(-45.0001);
// Returns the smallest integer value greater than or equal to x
cosine=cos(30*3.14159/180);
//for this first angle must be converted in radian
expo=exp(1.0);
// gives
e
to the power argument value
floatabs=fabs(-8.432);
// gives absolute value of float argument
Page 1 of 2

flo=floor(45.99356);
//Returns the largest integer value less than or equal to x.
nflo=floor(-45.99356);
//Returns the largest integer value less than or equal to x.
logbase_e=log(2.71828);
// calculates natural log of argument (i.e base e)
logbase_10=log10(100);
// calculates log of argument at base 10
power=pow(0.16,0.5);
// calculates power i.e pow(base, power) format
random=rand();
// generates random number
sq_root=sqrt(2.25);
// calculates squirroot of argument
printf("The absolute value of -8 is :
%d\n", ab);
printf("The ceil value of 45.0001 is : %lf\n", cel);
printf("The ceil value of -45.0001 is : %lf\n", ncel);
printf("The cos value of degree 30
is : %lf\n", cosine);
printf("The exponential
value of 1 is : %lf\n", expo);
printf("The absolute
value of double type argument -8.432 is : %lf\n", floatabs);
printf("The floor
value of 45.99356
is : %lf\n",
flo);
printf("The floor
value of -45.99356
is : %lf\n",
nflo);
printf("The natural log
value of 2.71829 is : %lf\n",
logbase_e);
printf("The log base 10 for
value 100 is : %lf\n",
logbase_10);
printf("The
value of pow(0.16,0.5)
is : %lf\n",
power);
printf("The random number is
: %d\n", random);
printf("The
value of sqrt(2.25)
is : %lf\n",
sq_root);
}
// end of main
Sample Output:
Page 2 of 2

#### You've reached the end of your free preview.

Want to read both pages?

- Spring '10
- zaman
- Continuous function, Logarithm, #include, Simple Standard Mathematical Library Functions