Increment and decrement

Description:

write a program to print the number in increment of two using ++ operator and -- operator Hint: a++ ++a a-- --a Test Case 1 Input (stdin) 1 Expected Output 1 3 3 1 Test Case 2 Input (stdin) 5 Expected Output 5 7 7 5

Program :

#include <iostream>

using namespace std;

 

main() {

   int a;

  cin>>a;

   int c ;

 

   // Value of a will not be increased before assignment.

   c = a++;  

   cout <<c<<"\n" ;

 

   // After expression value of a is increased

   //cout << "Line 2 - Value of a is :" << a << endl ;

 

   // Value of a will be increased before assignment.

   c = ++a;  

   cout<<c<<"\n" ;

  c = a--;

  cout<<c<<"\n";

  c = --a;

  cout<< c<<"\n";

   return 0;

}