C++ Arithmetic Operator increment operator

Description

C++ Arithmetic Operator increment operator

#include <iostream>
using namespace std;
int main()/*from   www  .  jav  a2 s  . c o  m*/
{
   int count = 10;
   cout << "count=" << count << endl;    //displays 10
   cout << "count=" << ++count << endl;  //displays 11 (prefix)
   cout << "count=" << count << endl;    //displays 11
   cout << "count=" << count++ << endl;  //displays 11 (postfix)
   cout << "count=" << count << endl;    //displays 12
   return 0;
}
#include <iostream>
using namespace std;
int main()/*  w ww . j  av  a2  s .c o  m*/
{
   int count;
   count = 0;
   cout << "The initial value of count is " << count << endl;
   count++;
   cout << "   count is now " << count << endl;
   count++;
   cout << "   count is now " << count << endl;
   count++;
   cout << "   count is now " << count << endl;
   count++;
   cout << "   count is now " << count << endl;
   return 0;
}



PreviousNext

Related