Page 87 - Modular_V1.1_Flipbook
P. 87
{
char ch; Output 1:
clrscr(); Enter any character: 5
Your entered character is a digit.
cout<<”Enter any character: “;
Output 2:
cin>>ch;
Enter any character: s
if(isalpha(ch))
Your entered character is a letter.
{
Output 3:
cout<<”Your entered character is a letter”;
Enter any character: &
} Your entered character is a symbol.
else if(isdigit(ch))
cout<<”Your entered character is a digit.”;
else
cout<<”Your entered character is a symbol.”;
getch();
}
FUNCTIONS OF MATH.H HEADER FILE
The math.h header file provides several mathematical and trigonometric functions that you can
use to perform various mathematical operations. Be sure to include math.h at the top of any
program. Some of the commonly used functions of the math.h header file are:
Function Name Use Example Output
ceil(a) It returns a after rounding up it to the nearest integer. ceil(2.3) 3
fabs(a) It returns the absolute value of a. fabs(-25.86) 25.86
floor(a) It returns a after rounding down it to the nearest floor(35.342) 35
integer.
fmod(a, b) It returns the floating-point reminder after fmod(2.3, 2) 0.3
dividing the a by b.
pow(a, b) It returns a raised to the power b. pow(2, 2) 4
sqrt(a) It returns the square root of a. The value of a must sqrt(49) 7
be greater or equal to zero.
cos(a) It returns the cosine of the angle a. The value of a cos(90) -0.448074
must be in radians.
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(90) -1.9952
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.
Header Files and Library Functions 85

