Operators in C Programming

In this post we will talk about Operators in C Programming but before that we will understand Expressions and Operands because both these terms will be used very often in this post.

In C programming there is a combination of expression variables, constants and operators which is written by following the syntax of C language.

By evaluating all C language expressions, its result value is assigned to a variable. I have given examples of expression below.

You can also read: Variables In C Programming

x = a * b - c
y = b + c * a
z = a - b * c + d;

Operands in C Programming

Operators and Operands both seem like words, so some programmers think that these two are the same term but in real it is not so.

To process any operation in our program, the values, variables or constants that are used with the operator are called operands. Let us understand from the expression given below.

c = a+b;

In the above expression c, a and b are operands, apart from these there are = and operators.

What are Operators in C Programming

Any programming language is incomplete without operators because there is hardly any computer program in which operators are not used.

Operators in C programming are special symbols whose meaning and use are already fixed. We use operators to perform specific mathematical or logical operations (tasks) in our C programs.

In C Programming Language also you get many types of operators from which you can do different things.

Operators in C Programming

Types of Operators

  • Arithmetic Operators
  • Assignment Operators
  • Relational Operators
  • Logical Operators
  • Conditional Operators or Ternary Operators
  • Increment and Decrement Operators
  • Bitwise Operators

You have understood what operators are and now you will understand the operators types one by one in details.

Arithmetic Operators

Operators in C Programming
Operators in C Programming

You are already familiar with Arithmetic Operators because since childhood we have been doing addition (+), subtraction (-), multiplication (*), division (/) and modulus (%).

You will get the basic information of arithmetic operators only after seeing the table given below, but I would suggest that for detailed information, you must read the tutorial thoroughly by clicking on the link given below.

OperatorNameDescription
+AdditionTo add operands
–SubtractionTo subtract the operands
*MultiplicationTo multiply in operands
/DivideTo participate in operands
%ModulusTo find the remainder by dividing the operands
Operators in C Programming

Assignment Operators

As we read above that arithmetic operators are used for mathematical operations.

With the help of arithmetic operators, assignment operators are used to evaluate (solve) the mathematical expression and assign its result to a variable.

Assignment operator ( = ) assigns (copy) the result value of the right side value, variable, constant or expression to the left side variable.

You will get the basic information of the assignment operators only after seeing the table and example given below, but I would suggest that for detailed information, you must read the tutorial thoroughly by clicking on the link given below.

OperatorNameDescription
=Simple AssignmentTo assign value to left side variable by solving right side values ​​or expression
+=Addition AssignmentTo assign to the left side variable by adding Left and Right side values ​​(variable)
-=Subtraction AssignmentTo assign the left and right side values ​​(variables) to the left side variables.
*=Multiplication AssignmentTo assign to the left side variable by multiplying the left and right side values ​​(variable)
/=Division AssignmentTo assign the left and right side values ​​(variable) to the left side variable by dividing
%=Modulo AssignmentTo assign the remainder to the left side variable by dividing the left and right side values ​​(variable)
Operators in C Programming

Relational Operators

Relational operators are used to compare the relationship of 2 values. These operators return 0 if the relationship is false and return a non-zero integer number if it is true.

You will get the basic information of relational operators only after seeing the table and example given below, but I would suggest that for detailed information, you must read the post thoroughly by clicking on the link given below.

OperatorNameDescription
==Equal toWhen the values ​​of both the operands are equal then True will return.
!=Not Equal toWhen the values ​​of both the operands are different then True will return.
<Less thanWhen the value of the left operand is less than the value of the right operand, then True will return.
>Greater thanWhen the value of the left operand is greater than the value of the right operand, then True will return.
<=Less than or equal toTrue will return when the value of the left operand is less than or equal to the value of the right operand.
>=Greater than or equal toTrue will return when the value of the left operand is greater than or equal to the value of the right operand.
Operators in C Programming

Logical Operators

As you read above, relational operators are used to define conditions.

Sometimes we have to define more than one condition in our programs which are related to each other and for this we use logical operators.

Logical Operators after examining the result values ​​(true, false) of all the conditions, returns false i.e. 0 and true i.e. non-zero integer number.

You will get the basic information of logical operators only after seeing the table and example given below, but I would suggest that for detailed information, you must read the tutorial thoroughly by clicking on the link given below.

OperatorNameDescription
&&ANDWhen all the conditions are true then True will return.
||ORWhen out of all the conditions if any one condition is true then True will return.
!NOTIt reverses the result of the condition i.e. true to false and false to true.
Operators in C Programming

Conditional Operator

We use conditional operator in decision making just like if-else statement. You can also say that this is a short form of if-else.

Conditional operator (ternary operator) uses two symbols ( ) and ( : ).

The condition comes before the question mark symbol ( ? ) and is followed by the true expression (statement) and the false expression comes after the colon mark ( : ).

(condition) ? true-expression : false-expression;

For detailed information of conditional operator with C Programs examples, you must read the tutorial thoroughly by clicking on the link given below.

Increment and Decrement Operators

Increment ( ++ ) and Decrement ( — ) operators are unary operators i.e. they are used only with a single variable.

With the help of the increment operator, the value of the variable gets incremented by 1 number and with the help of the decrement operator, the value of the variable gets decremented by 1 number.

You can also write x = x + 1 as ++x

You can also write x = x – 1 as – – x

For detailed information of increment and decrement operators with C Programs examples, you must read the tutorial thoroughly by clicking on the link given below.

I hope that you have liked this post. If you liked the post, then please share it with your friends and relatives and you can send your suggestion in the comment box below or email me at pr***********@gm***.com .

You can also visit my Hindi YouTube Channel.

Leave a Comment