#include <iostream>usingnamespace std;
int main()
{
int x = 5;
float y = 3.0;
x + 1; // Add one but doesn't change x
x = x + 1; // Add one to x, and store back into x
x += 1; // Shortcut for previous
y *= 1.5; // expands to
y = y * 1.5;
cout << y << "\n";
int z = 2;
z *= z + 1; // expands to z = z * (z+1) // note parens
cout << z << "\n";
// especially common to add or subtract 1 from an int
x = x + 1;
x += 1;
x++; // Add one, changes x, same as above// ++ is called "increment" operator
z--; // Subtract one, changes z
z -= 1; // These are all the same
z = z - 1; // -- is called "decrement" operator
++x; // Same as post-increment except for one detail
--z; // Same as post-decrement, except for one detail
x++; // adds one to x, changes x, but RETURNS old value
++x; // adds one to x, changes x, but RETURNS new value
cout << "A using postfix\n";
int a = 3;
cout << a << "\n"; // 3
cout << a++ << "\n"; // 3 (old value)
cout << a << "\n"; // 4
cout << "B using prefix\n";
int b = 3;
cout << b << "\n"; // 3
cout << ++b << "\n"; // 4 (new value)
cout << b << "\n"; // 4int d = 8;
int e = 4;
cout << ++d * e++ << "\n";
// 9 * 4 == 36return0;
}