C Programming

⌘K
  1. Home
  2. Docs
  3. C Programming
  4. Operators and Expression
  5. Arithmetic operators in C

Arithmetic operators in C

Arithmetic operators in C are used to perform mathematical operations such as addition, subtraction, multiplication, division, and modulus on numeric data types (e.g., int, float, double).

List of Arithmetic Operators:

OperatorNameDescriptionExample
+AdditionAdds two operandsa + b
-SubtractionSubtracts second operand from the firsta - b
*MultiplicationMultiplies two operandsa * b
/DivisionDivides first operand by seconda / b
%ModulusReturns remainder of division (integers)a % b

Note: The % operator only works with integers, not float or double.

Example Program Using Arithmetic Operators:

#include <stdio.h>

int main() {
    int a = 20, b = 7;

    printf("Addition: %d + %d = %d\n", a, b, a + b);
    printf("Subtraction: %d - %d = %d\n", a, b, a - b);
    printf("Multiplication: %d * %d = %d\n", a, b, a * b);
    printf("Division: %d / %d = %d\n", a, b, a / b);         // Integer division
    printf("Modulus: %d %% %d = %d\n", a, b, a % b);          // Note: %% to print %

    return 0;
}

Output:

Addition: 20 + 7 = 27
Subtraction: 20 - 7 = 13
Multiplication: 20 * 7 = 140
Division: 20 / 7 = 2
Modulus: 20 % 7 = 6

How can we help?

Discussion 0

Join the Conversation

Your email address will not be published. Required fields are marked *