Displaying sum's contents after each addition. - C++ Data Type

C++ examples for Data Type:Introduction

Description

Displaying sum's contents after each addition.

Demo Code

#include <iostream>
using namespace std;
int main()/*from w  ww .  j  ava  2s  .  co  m*/
{
   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;
}

Result


Related Tutorials