Curriculum / C / Lesson 04

Operators in C

Operators are symbols that perform operations on variables and values: doing math, comparing values, or combining logical conditions.C groups operators into a few families: arithmetic, relational (comparison), logical, and assignment..

4 of 11
beginner 📖 5 min read 🎯 1 question

Operators

Operators are symbols that perform operations on variables and values: doing math, comparing values, or combining logical conditions.

C groups operators into a few families: arithmetic, relational (comparison), logical, and assignment.

💡 Key insight The <code>%</code> (modulus) operator, which gives the remainder of a division, is one of the most interview-tested operators in C.

Syntax

syntax
a + b   a - b   a * b   a / b   a % b
a == b  a != b  a > b   a < b
a && b  a || b  !a
a = b   a += b  a -= b

Example

In C, comparison expressions like a == b evaluate to 1 (true) or 0 (false) — there's no separate boolean type in classic C.

c
#include <stdio.h>

int main() {
    int a = 10, b = 3;
    printf("Sum: %d\n", a + b);
    printf("Remainder: %d\n", a % b);
    printf("Is equal: %d\n", a == b);
    return 0;
}
outputSum: 13 Remainder: 1 Is equal: 0

Try it yourself

Copy this example into the C compiler and run it — try changing a value and see what happens.

Quick Quiz

1. What does 7 % 2 evaluate to in C?

Back to curriculum