0Pricing
C Academy · Lesson

Arithmetic Operators

+, -, *, /, %.

Arithmetic in C

C gives you the everyday math operators you already know. They let you turn variables into expressions that compute new values.

  • + addition
  • - subtraction
  • * multiplication
  • / division
  • % modulo (remainder)
#include <stdio.h>
int main(void) {
    int a = 7, b = 3;
    printf("a + b = %d\n", a + b);
    printf("a - b = %d\n", a - b);
    return 0;
}

Multiplication

The * operator multiplies two values. The result type follows the operands, so two int values produce an int.

#include <stdio.h>
int main(void) {
    int width = 4, height = 5;
    int area = width * height;
    printf("Area = %d\n", area);
    return 0;
}

All lessons in this course

  1. Arithmetic Operators
  2. Relational and Logical
  3. Assignment and Increment
  4. Operator Precedence
← Back to C Academy