Page 101 - Modular_V2.0_C++_Flikpbook
P. 101
Function Name Use Example Output
sin(a) It returns the sine of the angle a. The value of a sin(90) 0.893997
must be in radians.
tan(a) It returns the tangent of the angle a. The value of tan(45) 1.6198.
a must be in radians.
log(a) It returns the natural logarithm of a. The value of log(10) 2.302585
a must be positive.
log10(a) It returns the base-10 logarithm of a. The value of log10(10) 1
a must be positive.
Program 2: To use mathematical functions.
DOSBox 0.74, Cpu speed: max 100% cycles, Frameskip 0, Program:
#include<iostream.h>
The nearest integer of number is: -543
#include<conio.h>
The absolute value of number is: 543.429993
#include<math.h> The nearest round down value of number
is: -544
void main() The remainder is: 1
{ The value of a raised to the power b is:
225
clrscr(); The square root of 144 is: 12
The cosine of 45 degrees is 0.707388
float number = -543.43;
The natural logarithm of 10 is: 2.302585
float a = 15, b = 2;
double angle = 45 * (3.14 / 180);
cout<< "The nearest integer of number is: " << ceil(number);
cout<< "\nThe absolute value of number is: " << fabs(number);
cout<< "\nThe nearest round down value of number is: " << floor(number);
cout<< "\nThe remainder is: " << fmod(a, b);
cout<< "\nThe value of a raised to the power b is: " << pow(a, b);
cout<< "\nThe square root of 144 is: " << sqrt(144);
cout<< "\nThe cosine of 45 degrees is: " << cos(angle);
cout<< "\nThe natural logarithm of 10 is: " << log(10);
getch();
}
FUNCTIONS OF STDLIB.H HEADER FILE
The stdlib.h header file provides several general purpose functions for dynamic memory
management, random number generation, integer arithmetic, etc.
99
Header Files and Library Functions

