Precedence:
In C every operator has special precedence which is associated with it.The order in which different types of operators in an expression are evaluated is known as operator precedence. The operators which has higher precedence are executed first and operators which has lower precedence are executed later.
Example:
c = 25-{(5*4)/2} -10+4
c = 25-(20/2) - 10+4
c = 25-10-10+4
c = 15-10+4
c = 5+4
c = 9
Associativity:
The order in which operators of same precedence are evaluated is known as operator associativity. Operators which has same precedence level is evaluated from left to right.
Example:
Example:
Operators:
Operators are the symbols used to perform different kinds of calculation on different operands.
Types of Operators:
●Arithmetic
●Relational
●Logical
●Assignment
●Increment/Decrement
●Unary/Binary
Types of Operators:
●Arithmetic
●Relational
●Logical
●Assignment
●Increment/Decrement
●Unary/Binary
Arithematic:
The operator use to perform mathematical operations on different operands.It works with two values.
Relational :
Relational Operator:
Operator use to perform comparison between two values are called relational operators.Relational operators are:
< less than
> greater than
<= less than equal to
>= greater than equal to
= = equal to
!= not equal to
Operator use to perform comparison between two values are called relational operators.Relational operators are:
< less than
> greater than
<= less than equal to
>= greater than equal to
= = equal to
!= not equal to
Logical:
These are the Boolean which are used to perform logic's between two values.Answer will be in form of true and false
Assignment operator
Assignment operator is use to assign left hand side variable a value written on right hand side.
Example
a = 5;
Compound assignment statement
When we are assigning a value to two or more than two variables at one time.
Example
a = b = 5;
Compound assignment operator
The compound assignment operators consist of a binary operator and the simple assignment operator.They perform the operations on the two operands before assigning the result up to the first operand.
Assignment operator is use to assign left hand side variable a value written on right hand side.
Example
a = 5;
Compound assignment statement
When we are assigning a value to two or more than two variables at one time.
Example
a = b = 5;
Compound assignment operator
The compound assignment operators consist of a binary operator and the simple assignment operator.They perform the operations on the two operands before assigning the result up to the first operand.
Increment OperatorIncrease the value of the variable by one.It is a unary operator and works with one value.It is denoted by the symbol ++.Increment operator cannot increment the value of constants and expressions.
Decrement Operator
Decrease the value of variable by one.It is denoted by the symbol --.It is also a unary operator.
Post Fix
first value is saved then value is Increase/decrease by one.
example A++
Pre Fix
Value is Increase/decrease by one then then value is save.
example --S
Unary operator
The operator which require only one value for their operations is known as unary operator.
Example
X X!
T F
F T
Binary operator
The operator which require only two values for their operations is known as binary operator.
Example
X Y X && Y
T T T
T F F
F T F
F F F
Decrement Operator
Decrease the value of variable by one.It is denoted by the symbol --.It is also a unary operator.
Post Fix
first value is saved then value is Increase/decrease by one.
example A++
Pre Fix
Value is Increase/decrease by one then then value is save.
example --S
Unary operator
The operator which require only one value for their operations is known as unary operator.
Example
X X!
T F
F T
Binary operator
The operator which require only two values for their operations is known as binary operator.
Example
X Y X && Y
T T T
T F F
F T F
F F F