Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Arithmetic function in C programming language with example

Posted on September 7, 2017January 24, 2020

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);
Arithmetic function
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);
Arithmetic function
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);
Arithmetic function
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);

 

Arithmetic function
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);
Arithmetic function
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);
Arithmetic function
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);
Arithmetic function
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

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes