Variable increment and decrement in c/c++

· ++/-- operators there statement
a) Operand can come before or after the operator
b) In the equation it is apply only to the right sight not left sight :x=a++; not x++=a;
second equation will give produce error Lvalue required
·



  1. printf(“%d”,a++ ): first it will print a current value , if there is next printf statement or variable is occur in any expression then it will increase there variable value a.·
  2. printf(“%d”,--a ): first it will print a current value , if there is next printf statement or variable is occur in any expression then it will decrease there variable value a.·
  3. printf(“%d”,++a ): it will increase the value a;·
  4. printf(“%d”,--a ): it will decrease the value a;

Post a Comment

0 Comments