#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;

const int N = 20;

// file declaration and open
ifstream inFile;
ofstream outFile;
/*
need to open files here
*/

//function prototypes
void initialize(int& zeroCount, int& oddCount, int& evenCount);
void getNumber(int& num);
void classifyNumber(int num, int& zeroCount, int& oddCount, int& evenCount);
void printResults(int zeroCount, int oddCount, int evenCount);

int main()
{
    //variable declcaration
    int counter;
    int number;
    int zeros;
    int odds;
    int evens;
    
    initialize(zeros, odds, evens);
    
    cout<<"Please enter " << N << " integers."<<endl;
    cout<<"The numbers you entered are: "<<endl;
    
    for (counter=1; counter <= N; counter++)
    {
        getNumber(number);
        cout<<number<<" ";
        classifyNumber(number,zeros,odds, evens);
    } // end of for loop
    
    cout<< endl;
    printResults(zeros,odds,evens);
    
    inFile.close();
    outFile.close();
    system("PAUSE");
    return 0;
}

void initialize(int& zeroCount, int& oddCount, int& evenCount)
{
    zeroCount = 0;
    oddCount = 0;
    evenCount = 0;
}

void getNumber(int& num)
{
    cin>>num;
}

void classifyNumber(int num, int& zeroCount, int& oddCount, int& evenCount)
{
    switch(num%2)
    {
        case 0:  evenCount++;
                if (num == 0)
                  zeroCount++;
                break;
        case 1:
        case -1: oddCount++;
    } // end of switch
} // end classifyNumbe

void printResults(int zeroCount, int oddCount, int evenCount)
{
    cout<<"There are "<<evenCount << " evens, "
        <<"which includes "<<zeroCount<<" zeros"<< endl;
    cout<<"The number of odd numbers is: "<< oddCount<<endl;
} // end printResults

i have to modify the GETNUMBER function so that it gets the number from the file and reads it

This article has been dead for over six months. Start a new discussion instead.