Increment operators (++)
- Increment operators are increase the value of subsequent. value may be increase according to the programmer.
- Increment operator are two types as follows :
- Post increment
- Pre increment
Decrement operators ( -- )
- decrement operators decrease the value to one, two and so on.
- As like Increment operators, decrement operators are also two type as :
- Post decrement
- Pre decrement
Before we more discuss about increment and decrement operator, let understand some expression; that's are using in all operators.
Now some issues of pre and post increment and decrement, we will discuss after solve following programming :
Now some issues of pre and post increment and decrement, we will discuss after solve following programming :
x = 5 x = 5 x = 5
x = x+1 ++x x++
x = 6 x = 6 x=5
In above program u notice that value of x increase to one in all three expression but after the increasing one, the final value of x in not same, third box result is differ to another two boxes. Now you know that c operators are mostly three types, ++ and -- operators are Unary operators.
Post increment or decrement are lowest precedence so it is solve at the end of program. Hence above program in third box first value of x is print i.e. 5 after, it is increase.
Unary operators are solve right to left.
Post increment or decrement are lowest precedence so it is solve at the end of program. Hence above program in third box first value of x is print i.e. 5 after, it is increase.
Unary operators are solve right to left.
Q.1 Solve the expression in C language compiler ,assuming x,z are integer variables:
z = x++ + x++
where x=7
Ans.