Operators in C


 Operators 

An operator is a symbol that tells the compiler to perform specific mathematical or logical operations, based on the value provided. C language is rich in built-in operators and provides various operators which are given below:

1. Arithmetic Operators 

An arithmetic operator is used to perform mathematical calculations or operations such as Addition, subtraction, multiplication, division etc. on numerical values. The following arithmetic operators are: 

  • +(Addition) is used to add two operands. 
  • -(Subtraction) is used to subtract second operand from the first operand.
  • *(Multiplication) is used to multiple two/both operands.
  • /(Division) is used to divides the numerator by denominator.
  • %(Modular) is used to give remainder of after an integer division.

2. Relational Operators 

Relational operators are used to describe the relation between two operands. or you can say that relational operators are used to compare two operands. These are also known as Conditional operators. The following Relational operators are: 

  • == (double equal to) is used to checks if the values of two operands are equal or not. If yes, then the condition becomes true.
  • != (not equal to) is used to checks if the values of two operands are not equal. If the values are not equal, then the condition becomes true.
  • > (Greater than) is used to checks if the value of left operand greater than the value of right operand. If yes, the condition becomes true.
  • < (Less than) is used to checks if the value of left operand less than the value of right operand. If yes, the condition becomes true.
  • >= (Greater than equal to) is used to checks if the value of left operand greater than or equal to the value of right operand. If yes, the condition becomes true.
  • <= (Less than equal to) is used to check if the value of right operand less than or equal to the value of right operand. If yes, the condition becomes true.

3. Logical Operators

Logical operators are used to perform the logical operations. or whenever we want to check multiple conditions then we can use logical operators as well. The following logical operators are: 

  • && (Logical AND) if both the operands are non-zero then the condition becomes true.
  • || (Logical OR) if any of the two operands is non-zero then the condition becomes true.
  • ! (Logical NOT) is used to reverse the logical state of its operand. If a condition is True than logical not operator will make it False.














No comments:

Post a Comment