In C programming, arithmetic operators are used to perform basic mathematical operations. These operators take numerical values (either constants or variables) and return a single numerical value as a result.

List of Arithmetic Operators

OperatorDescriptionExample
+Additiona + b adds a and b
-Subtractiona - b subtracts b from a
*Multiplicationa * b multiplies a and b
/Divisiona / b divides a by b
%Modulus (remainder of division)a % b gives remainder of a/b

1. Addition Operator (+)

The addition operator adds two numbers.

Example:

Explanation:

In this example, the values of a and b are added together, and the result (30) is stored in sum.


2. Subtraction Operator (-)

The subtraction operator subtracts the second number from the first.

Example:

Explanation:

In this case, the value of b is subtracted from a, and the result (15) is stored in difference.


3. Multiplication Operator (*)

The multiplication operator multiplies two numbers.

Example:

Explanation:

Here, a and b are multiplied, and the result (20) is stored in product.


4. Division Operator (/)

The division operator divides one number by another.

Example:

Explanation:

The value of a is divided by b, and the result (4) is stored in quotient.

Note:

  • Integer Division: If both operands are integers, the result is an integer, and any fractional part is discarded.
  • Example: 7 / 2 will result in 3, not 3.5.

5. Modulus Operator (%)

The modulus operator returns the remainder of a division operation.

Example:

Explanation:

10 % 3 gives the remainder when 10 is divided by 3, which is 1.

Note:

  • The modulus operator is only used with integer types.

error: Content is protected !!
Open chat
1
Hi,how Can We Help You ?