C++ int type Totals eight input int values from the user

Description

C++ int type Totals eight input int values from the user

#include <iostream>
using namespace std;
const int NUM = 8;
void main()//from   w  w w  .  j  av a2 s. co  m
{
   int nums[NUM];
   int total = 0;      // Holds total of user's eight numbers.
   int ctr;
   for (ctr=0; ctr<NUM; ctr++)
   {
      cout << "Please enter the next number...";
      cin >> nums[ctr];
      total += nums[ctr];
   }
   cout << "The total of the numbers is " << total << "\n";
   return;
}



PreviousNext

Related