C++ Arithmetic Operator Displaying sum's contents after each addition.

Description

C++ Arithmetic Operator Displaying sum's contents after each addition.

#include <iostream>
using namespace std;
int main()//from w  w w.  j a  v  a 2 s  .  c  om
{
   int sum;
   sum = 0;
   cout << "The value of sum is initially set to " << sum << endl;
   sum = sum + 96;
   cout << "  sum is now " << sum << endl;
   sum = sum + 70;
   cout << "  sum is now " << sum << endl;
   sum = sum + 85;
   cout << "  sum is now " << sum << endl;
   sum = sum + 60;
   cout << "  The final sum is " << sum << endl;
   return 0;
}



PreviousNext

Related