C Programming/C Basics

C Operators

Updated on January 8, 2026
2 min read

C Programming Operators

Operators in C are special symbols used to perform operations on variables and values.

 They tell the compiler what operation to perform, such as addition, comparison, assignment, or logical checks.

Types of Operators in C

C operators are classified into the following main types:

  1. Arithmetic Operators
  2. Relational Operators
  3. Logical Operators
  4. Assignment Operators
  5. Increment and Decrement Operators
  6. Bitwise Operators
  7. Conditional (Ternary) Operator
  8. sizeof Operator

1. Arithmetic Operators

Used to perform mathematical calculations.

OperatorOperation
+Addition
-Subtraction
*Multiplication
/Division
%Modulus (remainder)

Example:

int a = 10, b = 3;
int sum = a + b;
int rem = a % b;

2. Relational Operators

Used to compare two values.

 The result is either true (1) or false (0).

OperatorMeaning
==Equal to
!=Not equal to
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal

Example:

if (a > b) {
    printf("a is greater");
}

3. Logical Operators

Used to combine conditions.

OperatorMeaning
&&Logical AND
||Logical OR
!Logical NOT

Example:

if (a > 0 && b > 0) {
    printf("Both are positive");
}

4. Assignment Operators

Used to assign values to variables.

OperatorExample
=a = 10
+=a += 5
-=a -= 2
*=a *= 3
/=a /= 2

Example:

a += 5;   // a = a + 5

5. Increment and Decrement Operators

Used to increase or decrease a value by 1.

OperatorMeaning
++Increment
--Decrement

Example:

int x = 5;
x++;   // x becomes 6

6. Bitwise Operators

Used to perform operations at the bit level.

OperatorOperation
&Bitwise AND
|Bitwise OR
^Bitwise XOR
~Bitwise NOT
<<Left shift
>>Right shift

Example:

int a = 5, b = 3;
int c = a & b;

7. Conditional (Ternary) Operator

Used as a short form of if–else.

Syntax:

(condition) ? value_if_true : value_if_false;

Example:

int max = (a > b) ? a : b;

8. sizeof Operator

Used to find the memory size of a data type or variable.

Example:

int x;
printf("%d", sizeof(x));

Operator Precedence (Important Concept)

Operator precedence decides which operator is evaluated first.

Example:

int result = 10 + 5 * 2;   // result = 20

* has higher precedence than +.

Key Points

  • Operators work on operands (variables or values)
  • Relational and logical operators return boolean results
  • Bitwise operators work at the binary level
  • Correct operator usage avoids logical and runtime errors

One-Line Exam Answer

Operators in C are symbols that perform operations on variables and values to produce a result.