C Operators

Beginner
16 min read
Updated: Nov 2026
1 example
10 guides

Definition and Usage

Operators are symbols that act on values (operands) to produce a result. C has arithmetic (+ - * / %), relational (< == >=), logical (&& || !), assignment (= +=), increment (++ --), bitwise (& | ^ ~ << >>), the conditional operator ?:, and sizeof. Precedence and associativity decide the order in which they run.

Bitmasks live here.

The bitwise pages teach the set/clear/toggle/test patterns behind flags and bitmasks, the same ideas used in drivers, protocols, and permission systems.

Learning Path

Work through the stages in order, or jump to a topic from the index below (10 tutorials).

C Examples

A quick taste of operators. Compile with gcc file.c -std=c11 -Wall -o out.

Example 1 — Several operators in one expression

Arithmetic, comparison, and a logical test combine into one decision.

C
#include <stdio.h>

int main(void) {
    int hours = 9;
    int rate = 20;
    int pay = hours * rate + 5;

    if (pay > 150 && hours >= 8) {
        printf("pay %d: bonus day\n", pay);
    }
    printf("overtime hours: %d\n", hours > 8 ? hours - 8 : 0);
    return 0;
}

How It Works

  1. * runs before +, so pay is 9 * 20 + 5 = 185.
  2. && needs both comparisons to be true.
  3. The ?: operator picks hours - 8 because hours > 8.

C Operators Topics

Every guide in this section with a one-line summary (10 tutorials).

Everyday operators

5 tutorials

Math, comparison, logic, assignment, and ++ / --.

TopicDescriptionTutorial
Arithmetic operatorsAdd, subtract, multiply, divide, and take remainders with + - * / %.Try it
Relational operatorsCompare values with == != < > <= >= and get 1 or 0.Try it
Logical operatorsCombine conditions with && (and), || (or), and ! (not).Try it
Assignment operatorsStore values with = and update them with += -= *= /= %= and friends.Try it
Increment and decrementUse ++ and -- in prefix and postfix form.Try it

Bits and masks

2 tutorials

Work on individual bits, including flag and bitmask patterns.

TopicDescriptionTutorial
Bitwise operatorsWork on individual bits with & | ^ ~ << >>.Try it
Bit manipulation techniquesSet, clear, toggle, and test bits, build bitmasks, and count set bits.Try it

Special operators

3 tutorials

The ternary operator, sizeof, and how precedence decides evaluation order.

TopicDescriptionTutorial
Conditional operatorChoose between two values in one expression with ?:.Try it
sizeof operatorFind the size in bytes of a type or object at compile time.Try it
Operator precedenceKnow which operators run first and how ties are broken.Try it

Edge Cases & Pitfalls

Common mistakes when learning operators in C.

= ==

Assignment instead of comparison

if (x = 5) assigns and is always true. Use == to compare.

prec

Trusting precedence you have not memorized

a & b == c parses as a & (b == c). Add parentheses when mixing operator families.

side

Side effects in one expression

i = i++ + ++i; is undefined behavior. Modify a variable once between sequence points.

Key Takeaways

  • Group: operators fall into a few families.
  • Parentheses: use them to show intent.
  • Bits: &, |, ^, and shifts power flags and masks.

One line: Operators are symbols that act on values (operands) to produce a result.

Frequently Asked Questions

C has roughly 45 operators across arithmetic, relational, logical, bitwise, assignment, conditional, pointer, member-access, comma, and sizeof categories.
= assigns a value; == compares two values and yields 1 or 0.
See the bitwise operators and bit manipulation techniques pages for flags, set/clear/toggle, and bit counting.

Next: Arithmetic Operators

Add, subtract, multiply, divide, and take remainders with + - * / %.

Continue →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful