| |
/* the program shows how to use math liabrary */
# include <iostream.h>
# include <math.h>
int abs ( void );
int log ( void );
int atof ();
int ceil ();
int exp ();
int pow ();
int sqrt ();
main()
{
log ();
abs ();
atof ();
ceil ();
exp ();
pow ();
sqrt ();
return 0;
}
int log ( void ) // how to use log
//logarithms function
{
double result;
double x = 8.6872;
result = log ( x );
cout << result << endl << endl;
return 0;
}
int abs () // how to use abs
//absolute value (positive from negative)
{
int a = - 2;
a = abs ( a );
cout << a << endl << endl;
return 0;
}
int atof () // how to use atof
//turn a string into a float
{
double c;
char b [] = { '1', '2', '3', '4' };
c = atof (b);
cout << c << endl << endl;
return 0;
}
int ceil () // how to use ceil
// highest number function
{
double d=2.9;
int e;
e = ceil ( d );
cout << e << endl << endl;
return 0;
}
int exp () // how to use exp
//exponents function
{
int f;
f = exp ( 3 );
cout << f << endl << endl;
return 0;
}
int pow () // how to use pow
//powers function
{
int p = 5;
int q;
q = pow ( p , 3 );
cout << q << endl << endl;
return 0;
}
int sqrt () // how to use sqrt
//square root function
{
int y = 9;
int z;
z = sqrt ( y );
cout << z << endl << endl;
return 0;
} |