Operator Types

What is Operator? Simple answer can be given using expression 4 + 5 is equal to
9. Here 4 and 5 are called operands and + is called operator. C language
supports following type of operators.

Lets have a look on all operators one by one.

Arithmetic Operators:

There are following arithmetic operators supported by C language:

Assume variable A holds 10 and variable holds 20 then:

Show Examples

Operator |
Description |
Example |

+ |
Adds two operands |
A + B will give 30 |

- |
Subtracts second operand
from the first |
A - B will give -10 |

* |
Multiply both operands |
A * B will give 200 |

/ |
Divide numerator by
denominator |
B / A will give 2 |

% |
Modulus Operator and
remainder of after an integer division |
B % A will give 0 |

++ |
Increment operator,
increases integer value by one |
A++ will give 11 |

-- |
Decrement operator,
decreases integer value by one |
A-- will give 9 |

Logical (or Relational)
Operators:

There are following logical operators supported by C language

Assume variable A holds 10 and variable holds 20 then:

Show Examples

Operator |
Description |
Example |

== |
Checks if the value of two
operands is equal or not, if yes then condition becomes true. |
(A == B) is not true. |

!= |
Checks if the value of two
operands is equal or not, if values are not equal then condition becomes
true. |
(A != B) is true. |

> |
Checks if the value of left
operand is greater than the value of right operand, if yes then
condition becomes true. |
(A > B) is not true. |

< |
Checks if the value of left
operand is less than the value of right operand, if yes then condition
becomes true. |
(A < B) is true. |

>= |
Checks if the value of left
operand is greater than or equal to the value of right operand, if yes
then condition becomes true. |
(A >= B) is not true. |

<= |
Checks if the value of left
operand is less than or equal to the value of right operand, if yes then
condition becomes true. |
(A <= B) is true. |

&& |
Called Logical AND operator.
If both the operands are non zero then then condition becomes true. |
(A && B) is true. |

|| |
Called Logical OR Operator.
If any of the two operands is non zero then then condition becomes true. |
(A || B) is true. |

! |
Called Logical NOT Operator.
Use to reverses the logical state of its operand. If a condition is true
then Logical NOT operator will make false. |
!(A && B) is false. |

NEXT >> Bitwise
Operators

Have a Question ?
post your questions here. It
will be answered as soon as possible.

Check
C Aptitude Questions
for more C Aptitude Interview Questions with Answers

Check
C Interview Questions
for more C Interview Questions with Answers