The document summarizes various mathematical and time-related functions available in standard C library header files like math.h, ctype.h, stdlib.h, time.h. It provides declarations and brief descriptions of functions for modulus calculations, trigonometric functions, hyperbolic functions, power calculations, floor/ceiling functions, logarithmic and exponential functions, string conversions, time/date manipulation and character classification/conversion.
2. This header file contains a number of pre-
defined/ library functions which performs
various mathematical calculations.
To include math.h header file in program use
preprocessor directive-
#include< math.h >
3. Modulus function calculates the remainder of
the division operation.
In ‘c’ modulus function is applied on integer
numbers only by default.
To apply modulus to floating point values we
use fmod , fmod l ,modf , modf l.
Modf / modf l splits double/ long double
number into integer and fractional part
respectively.
It stores the integer in ipart and returns the
fraction.
4. •Declaration :-
•Fmod , fmod l :-
double fmod (double x , double y);
long double fmod l(long double (x) , long double (y))
•Modf , modf l :-
double modf (double x , double *(ipart));
long double modf l(long double (x) , long double
*(ipart));
11. TO CALCULATE
POWER OF A
‘DESIRED’ NUMBER
TO CALCULATE
POWER OF ‘10’
pow
powl
Pow10
Pow10 l
12. Declaration :-
•Power :-
1. Double pow (double n , double p );
2. Long double pow (long double (n) , long double (p
3. Complex pow (complex n , complex p);
4. Complex pow (double n , complex p);
5. Complex pow (complex n , double p);
• Power10 :-
1. Double pow10 (int p);
2. Long double pow10 (int (p));
13. Floor function rounds the value down.
Floor returns integer found as double.
Floorl returns integer found as long double.
Declaration :-
double floor (double x);
long double floorl(long double (x));
14. Ceiling function rounds up a number.
Ceil returns an integer found as double.
Ceill returns an integer found as long double.
Declaration :-
double ceil (double x);
long double ceil (long double (x));
15. Exponential function is used to calculate the
powers of ‘e’.
For Real numbers ‘e’ raised to power ‘x’ is
calculated.
For complex numbers ‘e’ raised to power ‘z’ is
calculated (z is a complex number).
17. square root function is used to calculate the
square root of a given number.
Declaration :-
Real :-
double sqrt (double x);
long double sqrt (long double (x));
Complex :-
complex sqrt (complex x);
18. absolute value function returns only the numerical
value without any sign.
There are different types of abs function :-
o abs (a macro) finds absolute value of an integer .
o fabs , fabs l (macros) finds absolute values of
floating point values.
o Cabs , cabs l finds absolute values for complex
numbers.
o labs finds absolute values for long double values.
19. •Declaration :-
•abs :-
Real - int abs (int x);
Complex - complex abs (complex z);
•Fabs , fabd l :-
double fabs (double x);
long double fabs (long double @E(x));
•Cabs , cabd l :-
double cabs (struct_complex z);
long double cabd l (struct_complexl z);
•Labs :-
long int labs(long int x);
20. This header file contains prepackaged
functions to perform various operations on
‘characters’.
To include this header file in the program use
the preprocessor directive-
# include < ctype.h >
21. toupper is a function which converts lowercase
characters to uppercase characters. If the input
character is already uppercase character then
those characters remain unchanged.
_toupper is a macro which also converts
lowercase characters to uppercase characters.
But if the input characters have uppercase
characters in it then the result of _toupper is
‘undefined’.
23. tolower is a function which converts uppercase
characters to lowercase characters. If the input
character is already lowercase character then
those characters remain unchanged.
_tolower is a macro which also converts
uppercase characters to lowercase characters.
But if the input characters have lowercase
characters in it then the result of _tolower is
‘undefined’.
25. Isspace checks it out whether an input
character is a space , tab , carriage return , new
line , vertical tab , or formfeed or not.
It is a macro and returns a non-zero value on
success.
Declaration :-
int isspace ( int c );
26. The lower order byte of character is in the
range 0 to 127.
It is a macro and returns a non-zero value on
success.
Declaration :-
int isascii (int c);
27. Isprint checks it out whether the input
character is a printing character or not.
It is also a macro and returns a non-zero value
on success.
Declaration :-
int isprint (int c);
28. Isgraph checks it out whether input character is
a printing character or not like isprint except
that space character is excluded.
It is also a macro &returns non-zero value on
success.
Declaration :-
int isgraph (int c);
29. iscntrl checks it whether the input character is a
delete character or an ordinary control
character .
It is also a macro &returns non-zero value on
success.
Declaration :-
int iscntrl ( int c);
30. isxdigit checks out whether the input character
is a hexadecimal digit or not ( A to F , a to f , 0
to 9).
It is also a macro &returns non-zero value on
success.
Declaration :-
int isxdigit (int c);
31. To include this header file in the program use
the preprocessor directive-
# include < stdlib.h >
32. Abnormally terminates a process & writes a
termination message on stderr(“abnormal
program termination “) and then aborts the
program by a call to _exit with exit code 3.
Declaration :-
void abort (void);
33. atof converts a sting to floating point value .
_atold converts a string to long double.
Declaration :-
double atof (const char *s);
long double _atold (const char *(s));
34. It is a macro that converts the string to integer.
Declaration :-
int atoi (const char *s);
35. Swab function copies nbytes from the “from”
string to the “to” string .nbytes should be even
.
Adjacent even &odd bytes are swapped.
This is useful for moving data from one
machine to another machine in different bytes
order.
Declaration :-
void swab(char *from, char *to, int nbytes);
36. System invokes the DOS command interpreter
file from inside an executing ‘c’ program to
execute a DOS command ,batch file , or other
program named by the string “command”.
Declaration :-
int system (const char *command);
37. time.h header file contains various functions
operating on time .
Like clock, ctime, stime, time, difftime, acstime,
mktime, gmtime, localtime, etc.
To include this header file in the program use
preprocessor directive-
# include < time.h >
38. Clock returns the number of clock ticks since
program start.
Clock can be used to determine the time
interval between two events.
Declaration :-
clock_t clock (void);
39. Asctime converts date and time to ascii.
Ctime converts date and time to a string.
Declaration :-
char *acstime (const struct tm *tblock);
char *ctime (const time_t *time);
40. mktime converts time to calendar format .
Declaration :-
time_t mktime (struct tm *t);
41. time gets time of day.
stime gets system date and time.
Declaration :-
time_t time (time_t *timer );
int stime (time_t *tp);
43. Gmtime converts date and time to Greenwich
Mean Time (GMT).
Localtime converts date and time to a structure.
Declaration :-
struct tm *gmtime(const time_t *timer);
struct tm *localtime(const time_t *timer);