C Library –

C Library – <math.h> ”; Previous Next The math.h header defines various mathematical functions and one macro. All the functions available in this library take double as an argument and return double as the result. Library Macros There is only one macro defined in this library − Sr.No. Macro & Description 1 HUGE_VAL This macro is used when the result of a function may not be representable as a floating point number. If magnitude of the correct result is too large to be represented, the function sets errno to ERANGE to indicate a range error, and returns a particular, very large value named by the macro HUGE_VAL or its negation (- HUGE_VAL). If the magnitude of the result is too small, a value of zero is returned instead. In this case, errno might or might not be set to ERANGE. Library Functions Following are the functions defined in the header math.h − Sr.No. Function & Description 1 double acos(double x) Returns the arc cosine of x in radians. 2 double asin(double x) Returns the arc sine of x in radians. 3 double atan(double x) Returns the arc tangent of x in radians. 4 double atan2(double y, double x) Returns the arc tangent in radians of y/x based on the signs of both values to determine the correct quadrant. 5 double cos(double x) Returns the cosine of a radian angle x. 6 double cosh(double x) Returns the hyperbolic cosine of x. 7 double sin(double x) Returns the sine of a radian angle x. 8 double sinh(double x) Returns the hyperbolic sine of x. 9 tan(double x) Returns the tangent of a given angle(x). 10 double tanh(double x) Returns the hyperbolic tangent of x. 11 double exp(double x) Returns the value of e raised to the xth power. 12 double frexp(double x, int *exponent) The returned value is the mantissa and the integer pointed to by exponent is the exponent. The resultant value is x = mantissa * 2 ^ exponent. 13 double ldexp(double x, int exponent) Returns x multiplied by 2 raised to the power of exponent. 14 double log(double x) Returns the natural logarithm (base-e logarithm) of x. 15 double log10(double x) Returns the common logarithm (base-10 logarithm) of x. 16 double modf(double x, double *integer) The returned value is the fraction component (part after the decimal), and sets integer to the integer component. 17 double pow(double x, double y) Returns x raised to the power of y. 18 double sqrt(double x) Returns the square root of x. 19 double ceil(double x) Returns the smallest integer value greater than or equal to x. 20 double fabs(double x) Returns the absolute value of x. 21 double floor(double x) Returns the largest integer value less than or equal to x. 22 double fmod(double x, double y) Returns the remainder of x divided by y. 23 double round(double x) Returns the nearest integer value of x(rounded off values). Print Page Previous Next Advertisements ”;

C Library –

C Library – <ctype.h> ”; Previous Next The ctype.h header file of the C Standard Library declares several functions that are useful for testing and mapping characters. All the functions accepts int as a parameter, whose value must be EOF or representable as an unsigned char. All the functions return non-zero (true) if the argument c satisfies the condition described, and zero(false) if not. Library Functions Following are the functions defined in the header ctype.h − Sr.No. Function & Description 1 int isalnum(int c) This function checks whether the passed character is alphanumeric. 2 int isalpha(int c) This function checks whether the passed character is alphabetic. 3 int iscntrl(int c) This function checks whether the passed character is control character. 4 int isdigit(int c) This function checks whether the passed character is decimal digit. 5 int isgraph(int c) This function checks whether the passed character has graphical representation using locale. 6 int islower(int c) This function checks whether the passed character is lowercase letter. 7 int isprint(int c) This function checks whether the passed character is printable. 8 int ispunct(int c) This function checks whether the passed character is a punctuation character. 9 int isspace(int c) This function checks whether the passed character is white-space. 10 int isupper(int c) This function checks whether the passed character is an uppercase letter. 11 int isxdigit(int c) This function checks whether the passed character is a hexadecimal digit. 12 int isblank(int c) This function checks whether the passed character is a blank character. The library also contains two conversion functions that accepts and returns an “int”. Sr.No. Function & Description 1 int tolower(int c) This function converts uppercase letters to lowercase. 2 int toupper(int c) This function converts lowercase letters to uppercase. Character Classes Sr.No. Character Class & Description 1 Digits This is a set of whole numbers { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }. 2 Hexadecimal digits This is the set of { 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f }. 3 Lowercase letters This is a set of lowercase letters { a b c d e f g h i j k l m n o p q r s t u v w x y z }. 4 Uppercase letters This is a set of uppercase letters {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }. 5 Letters This is a set of lowercase and uppercase letters. 6 Alphanumeric characters This is a set of Digits, Lowercase letters and Uppercase letters. 7 Punctuation characters This is a set of ! ” # $ % & ” ( ) * + , – . / : ; < = > ? @ [ ] ^ _ ` { | } ~ 8 Graphical characters This is a set of Alphanumeric characters and Punctuation characters. 9 Space characters This is a set of tab, newline, vertical tab, form feed, carriage return, and space. 10 Printable characters This is a set of Alphanumeric characters, Punctuation characters and Space characters. 11 Control characters In ASCII, these characters have octal codes 000 through 037, and 177 (DEL). 12 Blank characters These are spaces and tabs. 13 Alphabetic characters This is a set of Lowercase letters and Uppercase letters. Print Page Previous Next Advertisements ”;

C Library –

C Library – <setjmp.h> ”; Previous Next The setjmp.h header defines the macro setjmp(), one function longjmp(), and one variable type jmp_buf, for bypassing the normal function call and return discipline. Library Variables Following is the variable type defined in the header setjmp.h − Sr.No. Variable & Description 1 jmp_buf This is an array type used for holding information for macro setjmp() and function longjmp(). Library Macros There is only one macro defined in this library − Sr.No. Macro & Description 1 int setjmp(jmp_buf environment) This macro saves the current environment into the variable environment for later use by the function longjmp(). If this macro returns directly from the macro invocation, it returns zero but if it returns from a longjmp() function call, then a non-zero value is returned. Library Functions Following is the only one function defined in the header setjmp.h − Sr.No. Function & Description 1 void longjmp(jmp_buf environment, int value) This function restores the environment saved by the most recent call to setjmp() macro in the same invocation of the program with the corresponding jmp_buf argument. Print Page Previous Next Advertisements ”;

C Library –

C Library – <time.h> ”; Previous Next The time.h header defines four variable types, two macro and various functions for manipulating date and time. Library Variables Following are the variable types defined in the header time.h − Sr.No. Variable & Description 1 size_t This is the unsigned integral type and is the result of the sizeof keyword. 2 clock_t This is a type suitable for storing the processor time. 3 time_t is This is a type suitable for storing the calendar time. 4 struct tm This is a structure used to hold the time and date. C Library Macros Following are the macros defined in the header time.h − Sr.No. Macro & Description 1 NULL This macro is the value of a null pointer constant. 2 CLOCKS_PER_SEC This macro represents the number of processor clocks per second. C Library time.h Functions Following are the functions defined in the header time.h − Sr.No. Function & Description 1 char *asctime(const struct tm *timeptr) Returns a pointer to a string which represents the day and time of the structure timeptr. 2 clock_t clock(void) Returns the processor clock time used since the beginning of an implementation defined era (normally the beginning of the program). 3 char *ctime(const time_t *timer) Returns a string representing the localtime based on the argument timer. 4 double difftime(time_t time1, time_t time2) Returns the difference of seconds between time1 and time2 (time1-time2). 5 struct tm *gmtime(const time_t *timer) The value of timer is broken up into the structure tm and expressed in Coordinated Universal Time (UTC) also known as Greenwich Mean Time (GMT). 6 struct tm *localtime(const time_t *timer) The value of timer is broken up into the structure tm and expressed in the local time zone. 7 time_t mktime(struct tm *timeptr) Converts the structure pointed to by timeptr into a time_t value according to the local time zone. 8 size_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr) Formats the time represented in the structure timeptr according to the formatting rules defined in format and stored into str. 9 time_t time(time_t *timer) Calculates the current calender time and encodes it into time_t format. 10 size_t wcsftime( wchar_t* str, size_t count, const wchar_t* format, const struct tm* time ) Converts a tm object to custom wide string textual representation. Print Page Previous Next Advertisements ”;

C Library –

C Library – <tgmath.h> ”; Previous Next The C library <tgmath.h> contains the headers <math.h> and <complex.h> and defines various types of macros. This function is applicable when real or complex function called on the basis of parameters(types). It allows computer programmer to express the mathematical operation which works with any floating type such as float, long, double and long double. We can use the single function name with regards to type and make the code easier to read. Syntax Following is the syntax of the C library header <tgmath.h> provides various built-in functions− pow(var1, var2) Or, fmod(var1, var2) Or, sin(var1, var2) etc. Parameter The above syntaxes uses various fuction which accepts only two parameters to express the mathematical expression. For example- finding the power of two numbers, getting trigonometric value, etc. The var1 and var2 belongs to same or different data types. Return Type The function returns based on the type of parameters passed to the macros. Ensure that, <tgmath.h> simplify the code maintenance and uses mathematical operation with the help of type-generic macros. Example 1 The C library header <tgmath.h> illustrate the function fmod() which accepts two parameters of different datatypes and calculates the remainders of the division of two numbers. #include <tgmath.h> #include <stdio.h> int main() { float f = 3.0f; double d = 3.0; // result is of type double double result = fmod(f, d); printf(“The result of fmod(%f, %f) = %fn”, f, d, result); return 0; } The above code produces the following result − The result of fmod(3.000000, 3.000000) = 0.000000 Example 2 Following example illustrates the usage of cabs() function that determine the abosolute value of complex number and display the result. #include <tgmath.h> #include <complex.h> #include <stdio.h> int main() { float complex fc = 3.0f + 4.0f * I; double complex dc = 3.0 + 4.0 * I; long double complex ldc = 3.0l + 4.0l * I; // res_fc is of type float float res_fc = cabs(fc); // res_dc is of type double double res_dc = cabs(dc); // res_ldc is of type long double long double res_ldc = cabs(ldc); printf(“cabs(%f + %fi) = %fn”, crealf(fc), cimagf(fc), res_fc); printf(“cabs(%f + %fi) = %fn”, creal(dc), cimag(dc), res_dc); printf(“cabs(%Lf + %Lfi) = %Lfn”, creall(ldc), cimagl(ldc), res_ldc); return 0; } On execution of above code, we get the following result − cabs(3.000000 + 4.000000i) = 5.000000 cabs(3.000000 + 4.000000i) = 5.000000 cabs(3.000000 + 4.000000i) = 5.000000 Example 3 Here, we use the trigonometric function to represent the value of data types − float, double, and long double. #include <tgmath.h> #include <stdio.h> int main() { float f = 3.0f; double d = 3.0; long double ld = 3.0l; // result_f is of type float double result_f = sin(f); // result_d is of type double double result_d = sin(d); // result_ld is of type long double double result_ld = sin(ld); printf(“The value of float [sin(%f)] = %fn”, f, result_f); printf(“The value of double [sin(%f)] = %fn”, d, result_d); printf(“The value of long [double sin(%Lf)] = %fn”, ld, result_ld); return 0; } After executing the above code, we get the following result − The value of float [sin(3.000000)] = 0.141120 The value of double [sin(3.000000)] = 0.141120 The value of long [double sin(3.000000)] = 0.141120 Print Page Previous Next Advertisements ”;

C Library –

C Library – <complex.h> ”; Previous Next The complex.h header file is part of the standard C library, defines various functions and macros for working with complex numbers. The complex number (Z) contains of both a real part and an imaginary part. A complex number represented as x + yi, where x is the real part, y is the imaginary part, and i is the imaginary unit (defined as the square root of -1). C − complex.h Types Following are the types defined in the header complex.h − Sr.No. Types & Description 1 imaginary This is imaginary type macro. 2 complex This is complex type macro. Manipulation Functions Following are the Manipulation functions − Sr.No. Function & Description 1 double complex CMPLX(double real, double imag) This function construct a complex number from real and imaginary part. 2 double creal( double complex z ) This function computes the real part of a complex number. 3 double cimag( double complex z ) This function computes the imaginary part of the complex number. 4 double cabs( double complex z ) This function calculate the magnitude of a complex number. 5 double carg( double complex z ) This function calculate the phase angle of a complex number. 6 double complex conj( double complex z ) This function calculate the complex conjugate. 7 double complex cproj( double complex z ) This function calculates the projection on Riemann sphere. Power Functions Following are the Power functions − Sr.No. Function & Description 1 double complex cpow( double complex x, double complex y ) This function calculates the complex power function. 2 double complex csqrt( double complex z ) This function calculates the complex square root. Exponential Functions Following are the Exponential functions − Sr.No. Function & Description 1 double complex cexp( double complex z ) This function calculates the complex base-e exponential. 2 double complex clog( double complex z ) This function calculates the complex natural logarithm. Trigonometric Functions Following are the Trigonometric functions − Sr.No. Function & Description 1 double complex csin( double complex z ) This function calculates the complex sine. 2 double complex ccos( double complex z ) This function calculates the complex cosine. 3 double complex ctan( double complex z ) This function calculates the complex complex tangent. 4 double complex casin( double complex z ) This function calculates the complex arc sine. 5 double complex cacos( double complex z ) This function calculates the complex arc cosine. 6 double complex catan( double complex z ) This function calculates the complex arc tangent. Hyperbolic Functions Following are the Hyperbolic functions − Sr.No. Function & Description 1 double complex csinh( double complex z ) This function calculates the complex hyperbolic sine. 2 double complex ccosh( double complex z ) This function calculates the complex hyperbolic cosine. 3 double complex ctanh( double complex z ) This function calculates the complex hyperbolic tangent. 4 double complex casinh( double complex z ) This function calculates the complex arc hyperbolic sine. 5 double complex cacosh( double complex z ) This function calculates the complex arc hyperbolic cosine. 6 double complex catanh( double complex z ) This function calculates the complex arc hyperbolic tangent. Print Page Previous Next Advertisements ”;