Arithmetic Function In C Programming

The arithmetic function is used for the arithmetic purpose in C Language

  • C programming language contains a lot of header files for various purposes.
  • One of the header file  #include<math.h>, is used to perform mathematical operations in a program called math function or arithmetic function
  • Some of the examples of arithmetic functions for abs(), floor(), round(), ceil(), sqrt(), exp(), log(), sin(), cos(), tan(), pow() and trunc()are explaind below
  • “math.h” and “stdlib.h” header files support all the arithmetic functions in C Language

abs(): This function returns the absolute value of an only integer.The absolute value of a number is always positive. abs() math function supports only integer value in C language and not any other datatype – float(fabs), double . #include<stdlib.h> header files are supported in this function.

Syntax

int abs(int x);

fabs(): This function returns the absolute value an only floating point value.The absolute value of a number is always positive only. fabs() maths function supported only floating point value in C language #include<math.h> header file supported of this function .

Syntax

double abs(double x);

labs(): This function returns the absolute value of an only long integer value. The absolute value of a number is always positive. labs() math function supports only long integer value in C language #include<math.h> header files are supported of this function .

Syntax

long int labs(long int x);

floor(): This function is the opposite of the ceil function and returns the nearest integer value which is less than or equal to the passing argument to this function(rounds dawns the nearest integer). This function include #include<math.h> header file

Syntax

double floor(double value);

ceil() : This function is opposite of the floor function and returns the nearest and smallest integer value which is greater than or equal(not less than) to the passing argument of this function. This function includes #include<math.h> header file

Syntax

double ceil(double value);

round() :This function returns the nearest integer value of the float or double or long double and passes the argument to the function.This function includes #include<math.h> header file

Syntax

double round(double value);

sin() : This function is use to calculate sine value. This function include #include<math.h> header file

Syntax

double sin(double value);

cos() : Thid function is used to calculate cosine value. This function includes #include<math.h> header file

Syntax

double cos(double value);

cosh() : This function calculates hyperbolic cosine value.This function includes #include<math.h> header file 

Syntax

double cosh(double value)

tan() : This function calculates tangent value.This function includes #include<math.h> header file

Syntax

double tan(double value);

tanh() : This function  performs  hyperbolic tangent value. This function includs #include<math.h> header file

Syntax

double tanh(double value);

sinh() : This function calculates hyperbolic sine value. This function includes #include<math.h> header file

Syntax

double sinh(double value);

exp() : This function calculates the exponential “e” to the nth power.This function includes #include<math.h> header file

Syntax

double exp(double value);

log(): This function calculates natural logarithm. This function includes #include<math.h> header file

Syntax

double log(double value);

log10() :  This function is use to perform  calculate base 10 logarithm. This function include #include<math.h> header file

Syntax

double log10(double value);

sqrt() : This function is used to find square root of the argument passed in this function. This function includes   #include<math.h> header file. This function includes #include<math.h> header file

Syntax

double sqrt(double value);

pow() : This is used to find the power of  given number. This function includes  #include<math.h> header file

Syntax

double pow(double value1, double value2);

trunc() : This function truncates the decimal value from floating point value and returns integer value. This function includes #include<math.h> header file

Syntax

trunc(number,[decimal_places]);
Follow Us On