Very common programming practice is adding or subtracting an integer variable by 1.
We know that adding 1 to variable is incrementing, and subtract 1 from variable is decrementing. It only works with integer values.
Let us see some examples
i++; i=i+1; i+=1;
This three commands are all the same. It increments the variable i by 1. Its the same for decrementing.
The incrementation and decrementation can be made with prefix of postfix
i++; //postfix ++i; //prefix
Here are some examples of using prefix and postfix
int j=++i; //1 int j=i--; //2
The above commands are equal to this
i++; //1 int j=i; int j=i; //2 i--;
or
i=i+1; //1 int j=i; int j=i; //2 i=i-1;
This operators are used in many programming languages, and are very simple for using.
As we know C++ is one lever above C, so, maybe the postfix was the inspiration for Bjarne Stroustrup to name the new programming language to C++ in 1979.
Enter your Name and Email below to subscribe and start 1 month free course now.








