increament operator

Current Categories - C-programming
 
*increament operators – It is an unary operator.it is used to add one to the variable.
*Symbol  : -" ++ "
e.g-consider k=5; then k++ will be eqaul to 6.
->It has two forms.
1.Prefix or preincrement
2.Postfix or postincrement

1.Preincrement :-The operator ++ presents before the operands.
Such  statement increment first and then execute. 
e.g -      Consider p=10 then.
preincrement is ++p.

2.Postincreament :-The operator ++ present after the operands.
such staement execute first and then increment.
e.g -consider p=10; then
postincrement is p++.

->now question arises in our mind that what is differeence between preincrement and postincrement.does the difference is only for the symbol notation i.e. after the operands or before the operands or is there any working(genuine) difference.

->yes there is genuine difference.To show the difference letus make one programm.


*Output:-
the value of a after preincrement is 7.
the value of b after postincrement is 6.

->now we see that in first statement the value is increased first then it is executed thats why the output is 7.
but in second statement the value is executed first after that it is increased so the output is as the value is i.e. 6.


copyright@@
MyFreeCopyright.com Registered & Protected
facebook-logo