Advertisement

Arithmetic Operators

C Language Operators 📅 May 2026 ⏱ 1 min read 🆓 Free

Arithmetic Operators in C

OperatorNameExampleResult
+Addition10 + 313
-Subtraction10 - 37
*Multiplication10 * 330
/Division (integer)10 / 33 (NOT 3.33!)
%Modulo (Remainder)10 % 31
++Increment (add 1)x++ or ++xx becomes x+1
--Decrement (minus 1)x-- or --xx becomes x-1
c
#include <stdio.h>

int main() {
    int a = 17, b = 5;
    
    printf("a + b  = %d\n", a + b);    // 22
    printf("a - b  = %d\n", a - b);    // 12
    printf("a * b  = %d\n", a * b);    // 85
    printf("a / b  = %d\n", a / b);    // 3 (integer division!)
    printf("a %% b = %d\n", a % b);    // 2 (17 = 5*3 + 2)
    
    // Float division — use 1.0 to get decimal result
    printf("17.0/5 = %.2f\n", (float)a / b);  // 3.40
    
    // Pre vs Post Increment
    int n = 10;
    printf("n++  = %d\n", n++); // prints 10 THEN increments (now 11)
    printf("n    = %d\n", n);   // 11
    printf("++n  = %d\n", ++n); // increments FIRST (now 12) THEN prints
    printf("n    = %d\n", n);   // 12
    
    return 0;
}
▶ Output
a + b  = 22
a - b  = 12
a * b  = 85
a / b  = 3
a % b = 2
17.0/5 = 3.40
n++  = 10
n    = 11
++n  = 12
n    = 12

Pre-increment vs Post-increment

OperationWhen Increment HappensEffect on Expression
++x (pre)BEFORE using in expressionExpression sees new value
x++ (post)AFTER using in expressionExpression sees original value
⚠ Warning: Integer division: 17 / 5 = 3, NOT 3.4! C drops the decimal part. To get 3.4, cast to float first: (float)17 / 5
Advertisement
← Back to C Language Index