Categories: C LanguageLearn C++

Arithmetic function in C programming language with example

Arithmetic function in C programming language with example

In this tutorial, we will discuss the arithmetic function in C programming language with example.

In the c programming language, arithmetic pre-defined functions is used to perform arithmetic calculation or other mathematical operations.

stdlib.h and math.h header files support all the arithmetic functions in C language

1. abs() – 

This arithmetic function in C language returns absolute value of a given integer.

Syntex

int abs(int value);
Example

 

2. floor() – 

This arithmetic function in C language returns the nearest integer value which is less than or equal to the given floating point argument value.

Syntex

double floor(double value);
Example
When the above code is executed, The following output is displayed
floor value of 15.1 is: 15.000000
floor value of 15.9 is: 15.000000
floor value of -15.1 is: -16.000000
floor value of -15.8 is: -16.000000


3. ceil() – 

This arithmetic function in C language returns the nearest integer value which is greater than or equal to the given floating point argument value.

Syntex

double ceil(double value);
Example

When the above code is executed, the following output is displayed

ceil value of 20.1 is: 21.000000
ceil value of 20.9 is: 21.000000
ceil value of -20.1 is: -20.000000
ceil value of -20.9 is: -20.000000

4. round() – 

This arithmetic function in C language returns the nearest integer value of the given float, double, long double argument value

Syntex

double round(double value);

 

Example

 

When the above code is executed, the following output is displayed
round value of 20.1 is: 20.000000
round value of 20.9 is: 21.000000
round value of -20.1 is: -20.000000
round value of -20.9 is: -21.000000
5.sin() –

This arithmetic function in c language returns the nearest float sine  value of the given  argument value

Syntex

double sin(double value);
Example
When the above code is executed, The following output is displayed
The sine value of 0.314 is : 0.308866
The sine value of 0.25 is : 0.247404
The sine value of 1 is : 0.841471
6. cos()-

This arithmetic function in c language returns the nearest float cosine value of the given  argument value

Syntex

double cos(double value);
Example

When the above code is executed, the following output is displayed

cosine value of 0.314 is : 0.951106
cosine value of 0.25 is : 0.968912

cosine value of 1 is : 0.540302

7. tan()-

This arithmetic function in c language returns the nearest float tangent value of the given  argument value

Syntex

tan(float value);
Example

When the above code is executed, the following output is displayed

The tangent value of 0.314 is : 0.324744
The tangent value of 0.25 is : 0.255342

The tangent value of 1 is : 1.557408

8.log()-

This arithmetic function in C language returns log of x to the base of e

Syntex

double log(double value);

When the above code is executed, the following output is displayed

The log value of 6.25 is : 1.832581
The log value of 10 is : 2.302585

The log value of 100 is : 4.605170

9.log10()-

This arithmetic function in C language returns log of x to the base of 10

Syntex

double log10(double value);

 

When the above code is executed, the following output is displayed

log value of 1.5 is: 0.176091
log value of 6.25 is: 0.812913

log value of 10 is: 1.000000

10.exp()-

This arithmetic function in C language returns the result of e raised to the power of x

Syntex

exp(double value);

When the above code is executed, The following output is displayed.

Exponential value of 2.1 is : 8.166170
Exponential value of 2.1 is : 181.272242
11.pow()-

This arithmetic function in C language returns x raised of to the power of y.

Syntex

pow(double value1,double value 2);

When the above code is executed, the following output is displayed

4.0 raised to the power of 2.0 is 16.000000
3.0 raised to the power of 5.0 is 243.000000
12.sqrt)-

This arithmetic function in C language returns the Square root of x

Syntex

sqrt(double value);
When the above code is executed, the following output is displayed
sqrt value of 81:9.000000
sqrt value of 50:7.071068
13.sinh()-

This arithmetic function in c language returns the hyperbolic sine of x

Syntex

sinh(double value);
When the above code is executed, the following output is displayed.

sinh value of 0.5 :0.521095
sinh value of 0.7 :0.758584

14.cosh()-

This arithmetic function in C language returns the hyperbolic cosine of x

Syntex

cosh(double value);
When the above code is executed, the following output is displayed.
cosh value of 0.5 :1.127626
cosh value of 0.7 :1.255169
14.tanh()-

This arithmetic function in C language returns the hyperbolic tangent of x

Syntex

cosh(double value);

When the above code is executed, the following output is displayed.

tanh value of 0.5 :0.462117
tanh value of 0.7 :0.604360

 

Suggested for you

Function in C language

String function in C language

String function in Python language

Arithmetic function in Python language

 

Karmehavannan

Recent Posts

Subtract two numbers using method overriding

Subtract two numbers using method overriding   Program 1

3 months ago

PHP Star triangle Pattern program

PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…

3 months ago

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

1 year ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

1 year ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

1 year ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

1 year ago

This website uses cookies.