What is an operator?
An operator is a symbol that instructs C to perform some operation on one or more operands. An operand is something that an operator acts on.
The different types of operator:
- Arithmetic operator: it is the basic and common operations and it is used to perform mathematical operations. It is known as binary operator since they take two operands to be evaluated. Different arithmetic operators are:
- Relational operator: C’s relational is used to compare expressions. It is used in conditional statement. Different relational operators are:
|Greater than or equal to||>=||x>=y|
|Less than or equal to||<=||x<=y|
|Not equal to||!=||x!=y|
- Logical operator: C’s logical operators let you combine two or more relational expression into a single expression that evaluates to either true or false. Different logical logical operators used are:
|AND||&&||Exp 1 && exp2|
|OR||||||Exp 1 || exp2|
|NOT||!||! exp 1|
- Assignment operator: The assignment operator is used to assign a value to a variable. The form is as follows:
Variable = expression:
Some assignment operator are: +=,-=,/=,%=.
The symbol = is used as assign operator.
- Increment/decrement operator:
|Increment||++||Increment the operate by one||++x, x–|
|Decrement||—||Decrement the operate by on||–x, x++|
- Ternary operator (condition operator): The ternary operator is C’s only ternary operator, meaning that it takes three operand, its syntax is
It is used for conditional statement.
can be written as z=(x>y)? x: y;
- Comma operator: It permits two different expression to appear in situation where only one expression to appear in situation where only one expression would ordinarily be used.
C = (a=10,b=20,a+b);
Printf (“= %d”,c);
Please follow and like us: