decreament operator

Current Categories - C-programming
 
*Decreament operators – It is an unary operator.it is used to subtract one from  the variable.
*Symbol  : -    " -- "
e.g-consider k=5; then k-- will be eqaul to 4.

->It has two forms.

1.Prefix or predecreament
2.Postfix or postdecreament

1.Predecreament :-The operator -- presents before the operands.
Such  statement decreament first and then execute. 
e.g -      Consider p=10 then.
predecreament is --p.

2.Postdecreament :-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 predecreament and postdecreament.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 predecreament is 5.
the value of b after postdecreament is 6.

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

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