Arithmetic Operations in C

The arithmetic operators are used to perform arithmetic/mathematical operations on operands. There are 9 arithmetic operators in C language:

S. No.

Symbol

OperatorDescription

Syntax

1

+

Plus

Adds two numeric values.

a + b

2

Minus

Subtracts right operand from left operand.

a – b

3

*

Multiply

Multiply two numeric values.

a * b

4

/

Divide

Divide two numeric values.

a / b

5

%

Modulus

Returns the remainder after diving the left operand with the right operand.

a % b

6

+

Unary Plus

Used to specify the positive values.

+a

7

Unary Minus

Flips the sign of the value.

-a

8

++

Increment

Increases the value of the operand by 1.

a++

9

Decrement

Decreases the value of the operand by 1.

a–

Example of C Arithmetic Operators

C
// C program to illustrate the arithmatic operators
#include <stdio.h>

int main()
{

    int a = 25, b = 5;

    // using operators and printing results
    printf("a + b = %d\n", a + b);
    printf("a - b = %d\n", a - b);
    printf("a * b = %d\n", a * b);
    printf("a / b = %d\n", a / b);
    printf("a % b = %d\n", a % b);
    printf("+a = %d\n", +a);
    printf("-a = %d\n", -a);
    printf("a++ = %d\n", a++);
    printf("a-- = %d\n", a--);

    return 0;
}

Output
a + b = 30
a - b = 20
a * b = 125
a / b = 5
a % b = 0
+a = 25
-a = -25
a++ = 25
a-- = 26


Operators in C

In C language, operators are symbols that represent operations to be performed on one or more operands. They are the basic components of the C programming. In this article, we will learn about all the built-in operators in C with examples.

Similar Reads

What is a C Operator?

An operator in C can be defined as the symbol that helps us to perform some specific mathematical, relational, bitwise, conditional, or logical computations on values and variables. The values and variables used with operators are called operands. So we can say that the operators are the symbols that perform operations on operands....

Types of Operators in C

C language provides a wide range of operators that can be classified into 6 types based on their functionality:...

1. Arithmetic Operations in C

The arithmetic operators are used to perform arithmetic/mathematical operations on operands. There are 9 arithmetic operators in C language:...

2. Relational Operators in C

The relational operators in C are used for the comparison of the two operands. All these operators are binary operators that return true or false values as the result of comparison....

3. Logical Operator in C

Logical Operators are used to combine two or more conditions/constraints or to complement the evaluation of the original condition in consideration. The result of the operation of a logical operator is a Boolean value either true or false....

4. Bitwise Operators in C

The Bitwise operators are used to perform bit-level operations on the operands. The operators are first converted to bit-level and then the calculation is performed on the operands. Mathematical operations such as addition, subtraction, multiplication, etc. can be performed at the bit level for faster processing....

5. Assignment Operators in C

Assignment operators are used to assign value to a variable. The left side operand of the assignment operator is a variable and the right side operand of the assignment operator is a value. The value on the right side must be of the same data type as the variable on the left side otherwise the compiler will raise an error....

6. Other Operators

Apart from the above operators, there are some other operators available in C used to perform some specific tasks. Some of them are discussed here:...

Unary, Binary and Ternary Operators in C

Operators can also be classified into three types on the basis of the number of operands they work on:...

Operator Precedence and Associativity in C

In C, it is very common for an expression or statement to have multiple operators and in these expression, there should be a fixed order or priority of operator evaluation to avoid ambiguity....

Conclusion

In this article, the points we learned about the operator are as follows:...

FAQs on C Operators

Q1. What are operators in C?...