/* testops2.cpp CIS 150 6/2/2005 David Klick Examples of increment and decrement operators. */ #include using std::cout; int main(void) { int x = 5; int y = 0; cout << " y x\n"; cout << "at start: " << y << ", " << x << '\n'; y = ++x; cout << "after y = ++x: " << y << ", " << x << '\n'; y = x++; cout << "after y = x++: " << y << ", " << x << '\n'; y = --x; cout << "after y = --x: " << y << ", " << x << '\n'; y = x--; cout << "after y = x--: " << y << ", " << x << '\n'; return 0; } /* Sample output: y x at start: 0, 5 after y = ++x: 6, 6 after y = x++: 6, 7 after y = --x: 6, 6 after y = x--: 6, 5 */