Shows use of auto-increment and auto-decrement operators. - C++ Operator

C++ examples for Operator:Increment and decrement operators

Description

Shows use of auto-increment and auto-decrement operators.

Demo Code

#include <iostream>
using namespace std;
int main() {/*from w ww .  j  a  v  a2  s .  co  m*/
   int i = 0;
   int j = 0;
   cout << ++i << endl; // Pre-increment
   cout << j++ << endl; // Post-increment
   cout << --i << endl; // Pre-decrement
   cout << j-- << endl; // Post decrement
}

Result


Related Tutorials