Operators are symbols that tell the compiler to perform specific mathematical or logical manipulations. C programs have
built-in operators and handle various types of operations. C operators are symbols that are used to perform mathematical
or logical operations on operands. Operands are the values that operators act upon. For example, in the expression
10 + 5
, 10
and 5
are operands, and +
is the operator.
Broad Types of C Operators
C operators can be broadly classified into the following categories:
- Unary Operators
- Binary Operators
- Ternary Operators
Unary Operators
Unary operators are operators that require only one operand to perform their operation. They are used to increment or decrement the value of the operand. The following are some examples of unary operators:
Increment Operator
The increment operator ++
is used to increase the value of the operand by 1. It can be used in two ways:
- Pre-increment: The value of the operand is incremented before it is used in the expression.
- Post-increment: The value of the operand is incremented after it is used in the expression.
Here are some examples of the increment operator:

Decrement Operator
The decrement operator --
is used to decrease the value of the operand by 1. It can be used in two ways:
- Pre-decrement: The value of the operand is decremented before it is used in the expression.
- Post-decrement: The value of the operand is decremented after it is used in the expression.
Here are some examples of the decrement operator:

Pointer Operator
The pointer operator *
is used to declare a pointer variable and to access the value
stored at the memory address pointed to by the pointer. The following are some examples of the pointer operator:

Address Operator
The address operator &
is used to get the memory address of a variable. It returns the address of the variable in memory. The following are some examples of the address operator:

Binary Operators
Binary operators are operators that require two operands to perform their operation. They are used to perform arithmetic, relational, logical, and bitwise operations. The following are some examples of binary operators:
Arithmetic Operators
Arithmetic operators are used to perform mathematical operations such as addition, subtraction, multiplication, division, and modulus. The following are some examples of arithmetic operators:
- Addition (+): Adds two operands.
- Subtraction (-): Subtracts the second operand from the first operand.
- Multiplication (*): Multiplies two operands.
- Division (/): Divides the first operand by the second operand.
- Modulus (%) : Returns the remainder of the division of the first operand by the second operand.
Here are some examples of arithmetic operators:

Relational Operators
Relational operators are used to compare two operands. They return a boolean value (true or false) based on the comparison. The following are some examples of relational operators:
- Equal to (==): Returns true if the two operands are equal.
- Not equal to (!=): Returns true if the two operands are not equal.
- Greater than (>): Returns true if the first operand is greater than the second operand.
- Less than (<): Returns true if the first operand is less than the second operand.
- Greater than or equal to (>=): Returns true if the first operand is greater than or equal to the second operand.
- >Less than or equal to (<=): Returns true if the first operand is less than or equal to the second operand.
Here are some examples of relational operators:

Logical Operators
Logical operators are used to perform logical operations on two boolean values. They return a boolean value based on the logical operation. The following are some examples of logical operators:
- Logical AND (&&): Returns true if both operands are true.
- Logical OR (||): Returns true if at least one of the operands is true.
- Logical NOT (!): Returns true if the operand is false.
Here are some examples of logical operators:

Assignment Operators
Assignment operators are used to assign values to variables. They are used to store the result of an expression in a variable. The following are some examples of assignment operators:
- Assignment (=): Assigns the value of the right operand to the left operand.
- Addition assignment (+=): Adds the value of the right operand to the left operand and assigns the result to the left operand.
- Subtraction assignment (-=): Subtracts the value of the right operand from the left operand and assigns the result to the left operand.
- Multiplication assignment (*=): Multiplies the value of the right operand with the left operand and assigns the result to the left operand.
- Division assignment (/=): Divides the value of the left operand by the right operand and assigns the result to the left operand.
- Modulus assignment (%=): Calculates the remainder of the division of the left operand by the right operand and assigns the result to the left operand.
Bitwise Operators
Bitwise operators are used to perform bitwise operations on integer operands. They operate on the binary representation of the operands. The following are some examples of bitwise operators:
- Bitwise AND (&): Performs a bitwise AND operation on the binary representation of the operands.
- Bitwise OR (|): Performs a bitwise OR operation on the binary representation of the operands.
- Bitwise XOR (^): Performs a bitwise XOR (exclusive OR) operation on the binary representation of the operands.
- Bitwise NOT (~): Performs a bitwise NOT (complement) operation on the binary representation of the operand.
- Left shift (<<): Shifts the bits of the left operand to the left by the number of positions specified by the right operand.
- Right shift (>>): Shifts the bits of the left operand to the right by the number of positions specified by the right operand.
Here are some examples of bitwise operators:

Ternary Operators
Ternary operators are operators that require three operands to perform their operation. They are used to evaluate a condition and return a value based on the result of the condition. The ternary operator is also known as the conditional operator. The following is an example of the ternary operator:
Conclusion
Operators are essential components of C programs that enable you to perform various mathematical and logical operations. Understanding the different types of operators and how they work is crucial for writing efficient and error-free code. By mastering C operators, you can create complex programs that perform a wide range of operations.
0 Comments