C++ Function Parameter void

Description

C++ Function Parameter void

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

void displayExplanation(void)
{
    cout << "Terminate the series by entering an\n"
         << "empty sequence.\n"
         << endl;/*from  ww w.  j  a va  2  s  . c o m*/
    return;
}

int sumSequence(void)
{
    int accumulator = 0;
    for(;;)
    {
        int nValue = 0;
        cout << "Enter next number: ";
        cin  >> nValue;

        if (nValue < 0)
        {
            break;
        }
        accumulator += nValue;
    }
    return accumulator;
}

int main(int nNumberofArgs, char* pszArgs[])
{
    displayExplanation();

    for(;;){
        cout << "Enter next sequence" << endl;
        int accumulatedValue = sumSequence();

        if (accumulatedValue == 0){
            break;
        }
        cout << "The total is " << accumulatedValue << endl << endl;
    }

    return 0;
}



PreviousNext

Related