# Function: Mathematical, Character and String Functions, Console Functions

Get unlimited access to the best preparation resource for UGC Library-Science: fully solved questions with step-by-step explanation- practice your way to success.

Download PDF of This Page (Size: 232K) ↧

### Mathematical Functions

Mathematical functions like sin (), cos (), etc. are defined in header file math.h.

Some of the important mathematical functions are given in the following table.

Some standard mathematical functions.

Function | Meaning |

sin(x) | Sine of an angle x (measured in radians) |

cos(x) | Cosine of an angle x (measured in radians) |

tan(x) | Tangent of an angle x (measured in radians) |

asin(x) | (x) where x (measured in radians) |

acos(x) | (x) where x (measured in radians) |

exp(x) | Exponential function of x |

log(x) | logarithm of x |

log10(x) | Logarithm of number x to the base 10 |

sqrt(x) | Square root of x |

pow (x, y) | x raised to the power y |

abs(x) | Absolute value of integer number x |

fabs(x) | Absolute value of real number x |

### Character Functions

All the character functions require ctype.h header file. The following table lists the function.

String | Functions |

is alpha(c) | It returns True if c is a Letter (A to Z or a to z) otherwise False. |

is digit(c) | It returns True if c is a digit (0 through 9) otherwise False. |

Is alnum(c) | It returns True if c is a digit from 0 through 9 or an alphabetic character (either uppercase of lowercase) otherwise False. |

slower(c) | It returns True if c is a lowercase letter otherwise False. |

Is upper(c) | It returns True if c is an uppercase letter otherwise False |

To upper(c) | It converts c to uppercase letter. |

To lower(c) | It converts c to lowercase letter |

### String Functions

The string functions are present in the string.h header file. Some string functions are given below:

Strlen (S) | It gives the no. of characters including spaces present in a string S. |

Strcat (S1, S2) | It concatenates the string S2 onto the end of the string S1. The string S1 must have enough locations to hold S2. |

Strcpy (S1, S2) | It copies character string S2 to string S1. The S1 must have enough storage locations to hold S2. |

Strcmp ((S1, S2) = =0) Strcmp ((S1, S2)>0) Strcmp ((S1, S2) <0) | It compares S1 and S2 and finds out whether S1 equal to S2, S1 greater than S2 or S1 less than S2. |

## Console I/O Functions

The following are the list of functions

The header file for above functions is stdio.h. The first two functions deal with single character and last two functions deal with string (group of characters).

### Get Char () Function

The get char () function returns a single character from a standard input device (keyboard).

It takes no parameter and the returned value is the input character.

The general form of the get char () function is:

A = get char ().

The variable A is of the type character. It inputs a character from the keyboard and assigns it to variable A.