NIOS Computer Science: Chapter 12 – Function Part 2

Download PDF of This Page (Size: 328K)

Image of Mathematical function

Image of Mathematical Function

Image of Mathematical function

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.

This Table show methematical function
This Table show methematical function

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.

This Table of character function
This Table of character function

String

Functions

isalpha(c)

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

isdigit(c)

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

isalnum(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.

isupper(c)

It returns True if c is an uppercase letter otherwise False

toupper(c)

It converts c to uppercase letter.

tolower(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:

This Table show String Functions
This Table show String Functions

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

Image of Console I/O functions

Image of Console I/O Functions

Image of Console I/O 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).

i). Getchar ( ) function

The getchar ( ) 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 getchar ( ) function is:

A = getchar( ) ;

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