x

C – Arithmetic Operators

Prev     Next

Arithmetic Operators in C:

C Arithmetic operators are used to perform mathematical calculations like addition, subtraction, multiplication, division and modulus in C programs.


Arithmetic Operators/Operation
Example
+ (Addition)
A+B
– (Subtraction)
A-B
* (multiplication)
A*B
/ (Division)
A/B
% (Modulus)
A%B

Example program for C arithmetic operators:

In this example program, two values “40” and “20” are used to perform arithmetic operations such as addition, subtraction, multiplication, division, modulus and output is displayed for each operation.

Output:

Addition of a, b is : 60
Subtraction of a, b is : 20
Multiplication of a, b is : 800
Division of a, b is : 2
Modulus of a, b is : 0

Continue on types of C operators:

Click on each operator name below for detailed description and example programs.


Types of Operators 
Description
Arithmetic_operators These are used to perform mathematical calculations like addition, subtraction, multiplication, division and modulus
Assignment_operators These are used to assign the values for the variables in C programs.
These operators are used to compare the value of two variables.
These operators are used to perform logical operations on the given two variables.
These operators are used to perform bit operations on given two variables.
Conditional operators return one value if condition is true and returns another value is condition is false.
These operators are used to either increase or decrease the value of the variable by one.
&, *, sizeof( ) and ternary operators.

Prev     Next



Like it? Please Spread the word!