Skip to main content

C Operators

2 min read
Share:
On this page (7sections)

Introduction

An operator is a symbol that tells the compiler to perform a mathematical or logical operation. C has a rich set of operators used in expressions, conditions and assignments.

Operators are grouped by the number of operands they take and the type of operation they perform. Each topic below links to a dedicated tutorial with syntax, example programs and sample output.

C Operator Categories

CategoryOperatorsTutorial
Arithmetic+, -, *, /, %Arithmetic Operators
Relational==, !=, <, >, <=, >=Relational Operators
Logical&&, ||, !Logical Operators
Assignment=, +=, -=, *=, /=, %=Assignment Operators
Unary++, --, +, -Unary Operators
Conditional (Ternary)? :Conditional or Ternary Operator
Bitwise&, |, ^, ~, <<, >>Bitwise Operators
Special,, (type) cast, sizeof, &, *Special Operators in C

Browse All Operator Tutorials

For the full list of operator example programs, visit the C Operators hub.

  1. Arithmetic Operator Example Program
  2. Relational Operators
  3. Logical Operators
  4. Assignment Operators
  5. Unary Operators
  6. Conditional or Ternary Operator
  7. Bitwise Operators
  8. Special Operators in C

Quick Example

#include <stdio.h>

int main(void) {
    int a = 10, b = 3;
    printf("Sum: %d\n", a + b);       /* arithmetic */
    printf("Equal? %d\n", a == b);    /* relational */
    printf("Both true? %d\n", a > 0 && b > 0);  /* logical */
    return 0;
}

Sample Output

Sum: 13
Equal? 0
Both true? 1

Continue learning with these related tutorials and programs:

Related Tutorials

Search tutorials