blogBannerImg
JaroEducation
July 23, 2025

Operators in C Language: Types and Examples

In the realm of programming, operators play a key role in performing operations on variables and values. And, when it comes to the C language – one of the most popular and widely used programming languages—understanding the role of these operators is crucial to writing efficient and effective code.

Operators in C are special symbols or keywords that instruct the compiler to perform specific operations. They are used for versatile purposes like arithmetic calculations, determining relations, decision-making, calculating memory size, and more.

The following write-up will explore different types of operators in the C language, their functionalities, and syntaxes for a detailed understanding.

Table Of Content

Types of Operators in C

Other Types of Operators in C

Significance of Operators in C

Unlocking Tech Potential with a Comprehensive BCA Program

Conclusion

Frequently Asked Questions

Types of Operators in C

Operators in C

*logicmojo.com

Operators in C help to perform different types of operations between the variables or values. They are used in the expressions to conduct their tasks. So, the expressions are the combinations of variables, operators, and constants. The data items on which the operators act are called the operands. 

Here are the different types of operators used in C –

Arithmetic operators in C

The basic mathematical operations in the C programming language are performed by arithmetic operators. These include basic addition, subtraction, division, multiplication, modulus, etc. These operators in C work on numeric data types. That means they work on integer and float data types. They help to perform both the simple and complex operations efficiently. 

SymbolOperatorDescriptionSyntax
+PlusSimple addition of two numeric values.a + b
MinusSimple subtraction from left operand to right operand.a – b
*MultiplyMultiply two numeric values.a * b
/DivideDivide two numeric values.a / b
%ModulusReturns the remainder after dividing the left operand by the right operand.a % b
+Unary PlusUsed to specify the positive values.+a
Unary MinusFlips the sign of the value.-a
++IncrementIncreases the value of the operand by 1.a++
DecrementDecreases the value of the operand by 1.a–

Example of arithmetic operators in C

#include 

int main()

{

    int a = 25,b = 10, c;    

    c = a+b;

    printf(“a+b = %d n”,c);

    c = a-b;

    printf(“a-b = %d n”,c);

    c = a*b;

    printf(“a*b = %d n”,c);

    c = a/b;

    printf(“a/b = %d n”,c);

    c = a%b;

    printf(“Remainder when a is divided by b = %d n”,c);   

    return 0;

}

Output:

a+b = 35
a-b = 15
a*b = 250
a/b = 2

The remainder when a divided by b = 5

Logical operators in C

Logical operators in C combine conditions for returning true or false. For true, the output will be 1 and 0 for false. These operators help in deciding mankind in the conditional statements like if, for, and while. 

SymbolOperatorDescriptionSyntax
&&Logical ANDReturns true if both the operands are true.a && b
||Logical ORReturns true if both or any of the operand is true.a || b
!Logical NOTReturns true if the operand is false.!a

Example of logical operators in C

// Working of logical operators

#include 

int main()

{

    int a = 36, b = 36, c = 42, results;

    results = (a == b) && (c > b);

    printf(“(a == b) && (c > b) is %d n”, results);

    results = (a == b) && (c < b);

    printf(“(a == b) && (c < b) is %d n”, results);

    results = (a == b) || (c < b);

    printf(“(a == b) || (c < b) is %d n”, results);

    results = (a != b) || (c < b);

    printf(“(a != b) || (c < b) is %d n”, results); results = !(a != b); printf(“!(a != b) is %d n”, results); results = !(a == b); printf(“!(a == b) is %d n”, results); return 0; 

}

Output

(a == b) && (c > b) is 1 

(a == b) && (c < b) is 0 

(a == b) || (c < b) is 1 

(a != b) || (c < b) is 0 

!(a != b) is 1 

!(a == b) is 0

Relational operators in C

These operators in C determine the relations between the values of two operands during the operations. For example, they can determine whether one operand is greater than another, smaller than or equal to another. 

SymbolOperatorDescriptionSyntax
<Less thanReturns true if the left operand is less than the right operand. Else falsea < b
>Greater thanReturns true if the left operand is greater than the right operand. Else falsea > b
<=Less than or equal toReturns true if the left operand is less than or equal to the right operand. Else falsea <= b
>=Greater than or equal toReturns true if the left operand is greater than or equal to the right operand. Else falsea >= b
==Equal toReturns true if both operands are equal.a == b
!=Not equal toReturns true if both operands are NOT equal.a != b

Example of relational operators in C

#include <stdio.h>

int main() {

    int a = 51, b = 7;

    // using operators and printing results

    printf(“a < b  : %d\n”, a < b);

    printf(“a > b  : %d\n”, a > b);

    printf(“a <= b: %d\n”, a <= b);

    printf(“a >= b: %d\n”, a >= b);

    printf(“a == b: %d\n”, a == b);

    printf(“a != b : %d\n”, a != b);

    return 0;

}

Output

a < b  : 0

a > b  : 1

a <= b: 0

a >= b: 1

a == b: 0

a != b : 1

Bitwise operators in C

Bitwise operators in C enable operations for bit by bit of the integer values. So, these operators are used in bitwise operations for the integers that are significant in low-level programming, hardware interactions, and cryptography. These operations are performed as a binary aspect.

SymbolOperatorDescriptionSyntax
&Bitwise ANDPerforms a bit-by-bit AND operation and returns the result.a & b
|Bitwise ORPerforms a bit-by-bit OR operation and returns the result.a | b
^Bitwise XORPerforms a bit-by-bit XOR operation and returns the result.a ^ b
~Bitwise First ComplementFlips all the set and unset bits on the number.~a
<<Bitwise Left ShiftShifts the number in binary form by one place left in the operation and returns the result.a << b
>>Bitwise Right ShiftShifts the number in binary form by one place right in the operation and returns the result.a >> b

Example of bitwise operators in C

#include <stdio.h>

int main() {

    int a = 45, b = 9;

    // using operators and printing results

    printf(“a & b: %d\n”, a & b);

    printf(“a | b: %d\n”, a | b);

    printf(“a ^ b: %d\n”, a ^ b);

    printf(“~a: %d\n”, ~a);

    printf(“a >> b: %d\n”, a >> b);

    printf(“a << b: %d\n”, a << b);

return 0;

}

Output

a & b: 9

a | b: 45

a ^ b: 36

~a: -46

a >> b: 5

a << b: 360

Assignment operators in C

To assign the values to the variables, the assignment operators in C are used. ‘=’ is the basic assignment operator that assigns a value (right hand) to a variable (left hand). Additionally, C also includes more compound assignment operators like +=, -=, etc.

SymbolOperatorDescriptionSyntax
=Simple AssignmentAssign the value of the right operand to the left operand.a = b
+=Plus and assignAdd the right operand and left operand and assign this value to the left operand.a += b
-=Minus and assignSubtract the right operand and left operand and assign this value to the left operand.a -= b
*=Multiply and assignMultiply the right operand and left operand and assign this value to the left operand.a *= b
/=Divide and assignDivide the left operand with the right operand and assign this value to the left operand.a /= b
%=Modulus and assignAssign the remainder in the division of left operand with the right operand to the left operand.a %= b
&=AND and assignPerforms bitwise AND and assigns this value to the left operand.a &= b
|=OR and assignPerforms bitwise OR and assigns this value to the left operand.a |= b
^=XOR and assignPerforms bitwise XOR and assigns this value to the left operand.a ^= b
>>=Right Shift and assignPerforms a bitwise right shift and assigns this value to the left operand.a >>= b
<<=Left Shift and assignPerforms a bitwise left shift and assigns this value to the left operand.a <<= b

Example of assignment operators in C

// C program to demonstrate assignment operators

#include <stdio.h>

int main() {

    int a = 11, b = 6;

    // Basic assignment

    a = b;

    printf(“a = %d\n”, a);  // a becomes 5

    // Compound assignment operators

    a += 3;  // equivalent to a = a + 3

    printf(“a += 3 -> %d\n”, a);

    a *= 2;  // equivalent to a = a * 2

    printf(“a *= 2 -> %d\n”, a);

    a -= 4;  // equivalent to a = a – 4

    printf(“a -= 4 -> %d\n”, a);

    a /= 3;  // equivalent to a = a / 3

    printf(“a /= 3 -> %d\n”, a);

    return 0;

}

Output

a = 6

a += 3 -> 9

a *= 2 -> 18

a -= 4 -> 14

a /= 3 -> 4

Other Types of Operators in C

Apart from the above mentioned operators, there are some special operators in C. Here is the list of those operators –

SymbolOperatorDescriptionSyntax
? :Ternary or conditionalA type of if-else statement, but a shorthandcondition? a : b
,CommaHelps to separate expressions in a list, evaluated from left to right.a, b
.Member access (Direct)To access the members of a union or structure directlystructure.member
()Function callExecutes a functionfunction()
[]Array subscriptTo access the elements of an arrayarray[index]
sizeofSizeofTo return the size of the variables or data types in bytessizeof(a) or sizeof(int)
->Member access (Indirect)To access the members of a union or structure through a pointerpointer->member
*Pointer dereferenceTo access the value pointed to by a pointer*ptr
(type)Type castTo convert a value from one data type to another, explicitly(int)float_var
&Address-ofTo return the memory address of a variable&variable

Significance of Operators in C

Here is why the operators in C are necessary –

  • Perform mathematical calculations: The arithmetic operators in C help to perform the basic mathematical calculations such as addition, multiplication, subtraction, and division. 
  • Maintain the program’s flow: The logical operators in C help in the decision-making process of conditional statements. This way, they maintain the program’s flow and reduce code redundancy. 
  • Improve readability: The ternary operators make the conditional logic readable and concise. 
  • Handle pointers and memory: Special operators like * and & are mandatory to efficiently handle operations regarding pointers, manipulation, and memory allocation. 
  • Simplify code: The operators like arithmetic and assignment simplify the code by reducing the necessity of writing longer expressions.

Operatos C

*logicmojo.com

Unlocking Tech Potential with a Comprehensive BCA Program

C programming is a fundamental topic of computer science. It also provides the core concepts that help individuals to learn other programming languages. So, individuals interested in the C programming language should take a profession certification course that helps in their career growth. For example, they can take the Online BCA Programme – Manipal University Jaipur.

The course not only covers C programming but also covers advanced technologies like cloud technology, Big Data, machine learningDBMS, etc. Apart from these, the course also guides the students to gain knowledge about financial accounting and management, personality development, and building impactful communication skills. These ways, the program supports the students to get ready for the dynamic world of the corporate sector.

Conclusion

So, this guide covered all the major operators in C. The operators are the core concepts of any programming language, and without them, the code can’t stand at all. Thus, students need extensive knowledge about the operators to efficiently write code in any programming language and improve their career prospects.

Operators are the symbols that instruct computers to perform specific operations. They are the pillars of a code that helps to manipulate data and build logic.

The logical operators are those that work with the Boolean conditions.

++a is the pre-increment, which indicates increments before use. However, a++ is the post-increment, which means increments after use.
EllispeLeftEllispeRight
whatsappImg