Increment and Decrement Operators


Compile this code (either re-type or copy and paste) into a project called inc_dec_ex. Print a copy of your code and the program output. In your code, you should add comments that explains what each command does.

//increment and decrement operator examples


#include <iostream>
using namespace std;


int main()
{
	//increment examples
	int x = 3;
	cout << "Original x" << x << endl;
	cout << "++x " << ++x << endl;	
	cout << "x++ " << x++ << endl;	
	cout << "Final x " << x << endl;		
	
	//decrement examples
	int y = 10;
	cout << "\n\nOriginal " << y << endl;
	cout << "--y " << --y << endl;	
	cout << "y-- " << y-- << endl;	
	cout << "Final y " << y << endl;		

	return 0;

} //end of main