There are three types of operators in C :
- Unary Operator
- Binary Operator
- Ternary Operator
Unary operators consist of either a unary operator pretended to be an operand or the size of a keyword followed by an expression. The expression can be either the name of a variable or a cast expression.
A binary expression consists of two operands joint by a binary operator.
A ternary expression consists of three operands joint by the conditional expression operator.
1. Arithmetic Operator:
Arithmetic operators are used for numeric calculations.
There are five Arithmetic operators
+ ( Addition )
– ( Subtraction)
* (Multiplication )
/ ( Division )
% (Percentage (modulus))
2. Assignment operator:
A value can be stored in a variable with the use of an assignment operator. This assignment operator “=” is used to assign expression and assignment expression. The operands on the left-hand side should be a variable while the operand on the right-hand side can be any variable, constant or expression. The examples of assignment expression are :
A relational operator is used to comparing values of two expressions depending on their relationship. An expression that contains relational operators is called Relational expression. If the relation is true then the values of relational expression are 1 and if the relational expression is false then the value of the relational expression is 0.
The relational operators are- < , <= , == ,> , >=
An expression that combines two or more expression is termed as a logical expression. For combining these expressions we use logical operators. These operators return 0 for false and 1 for true. The operators may be constant, variable or expression.
‘C” has three logical operators :