New Member to the site, but an active searcher of the site to find answers.

This one is a bit confusing for me to figure out... Hopefully after reading the source file you can help with my dilemma.

Program: Store an array of numbers (manually/from file); Scan the array and count the numbers between certain ranges. (0-24, 24-49, 50-74 and so on until 200); Then display the count either on screen or saved to a .txt file.

```
    // Program for teachers to input test grades.
    // Test scores range from 0-200.
    // Test scores can either be input by file, or manually.
    // Program will then display the number of test scores that falls
    //  into quarter ranges.
    // Display options are either on screen or in file.

    #include "stdafx.h"
    #include <iostream>
    #include <fstream>

    using namespace std;

    // Due to being new with functions, I was not sure if these variables
    //  need to be constant or not...
    char scores;
    int students;
    int i,n, list[100];
    void openinfile(ifstream &infile);
    void openoutfile(ofstream &outfile);
    int count(int x, int y);
    ifstream inputfile;
    ofstream outputfile;

    // Using VS2013
    // Main program for options menu's and algorithms.
    int main(int argc, char *argv[])
    {

int total;
int qMenu1;
int qMenu2;

cout << "How many students are in your class?" << endl;
cin >> students;
cout << "How would you like to enter your test scores?" << endl;
cout << "1 - From File." << endl;
cout << "2 – Manually." << endl;
cin >> qMenu1;

if (qMenu1 = 1)
    openinfile(inputfile);

else if (qMenu1 = 2)
{   
    cout << "Please enter total number of students." << endl;
    cin >> students;            // Store array size in students.

    // Sets up the array for the user to enter all grades, 1 by 1
    // until the the entries = max number of array slots.
    for (i=0; i<students-1; i++)    
    {
        cout << "Enter test score #" << i << ":" << endl;
        cin >> list[i];
    }
}
else 
{
    cout << "Please enter a valid Number." << endl;
    cout << "(1 or 2)" << endl;
}

// Menu2: Display options. (On Screen or Save to File)
cout << "How would you like your results displayed?" << endl;
cout << "1 – On Screen." << endl;
cout << "2 – To File." << endl;
cin >> qMenu2;

if (qMenu2 = 1)
{
    cout << "TOTAL NUMBER OF STUDENTS WITHIN RANGE:" << endl;
    cout << endl;
    total = count(0, 24);           // Quarter ranges that the input 
    cout << "000 – 024\t" << total << endl; // needs to be checked against.
    total = count(25, 49);
    cout << "025 – 049\t" << total << endl;
    total = count(50, 74);
    cout << "050 – 074\t" << total << endl;
    total = count(75, 99);
    cout << "075 – 099\t" << total << endl;
    total = count(100, 124);
        cout << "100 – 124\t" << total << endl;
    total = count(125, 149);
        cout << "125 – 149\t" << total << endl;
    total = count(150, 174);
        cout << "150 – 174\t" << total << endl;
    total = count(174, 200);
        cout << "174 – 200\t" << total << endl;
}   
else
{
    openoutfile(outputfile);    

    outputfile << "TOTAL NUMBER OF STUDENTS WITHIN RANGE:" << endl;
    outputfile << endl;
    total = count(0, 24);
    outputfile << "000 – 024\t" << total << endl;
    total = count(25, 49);
    outputfile << "025 – 049\t" << total << endl;
    total = count(50, 74);
    outputfile << "050 – 074\t" << total << endl;
    total = count(75, 99);
    outputfile << "075 – 099\t" << total << endl;
    total = count(100, 124);
        outputfile << "100 – 124\t" << total << endl;
    total = count(125, 149);
        outputfile << "125 – 149\t" << total << endl;
    total = count(150, 174);
        outputfile << "150 – 174\t" << total << endl;
    total = count(174, 200);
        outputfile << "174 – 200\t" << total << endl;

    outputfile.close();     

    return 0;
}

    }

// Function to open file for reading and input in array.
void openinfile(ifstream &infile)
{
    char filename[100];

    cout << "Enter the file name: ";
    cin >> filename;
    infile.open(filename);

    if (infile.fail())
        cout << filename << "\tDoes not exist" << endl;

    else
    {
        cout << filename << "Successfully open" << endl;
    // read character until the end of file.
        for (int i = 0; i < 100; i++) 
        {
            infile >> list[i];
        }
    }
}

// function to open new file for writing result to.
void openoutfile(ofstream &outfile)
{
    char filename[100];

    cout << "Enter the file name to save.";
        cin >> filename;

    outfile.open(filename);
    if (outfile.fail())
    {
        cout << filename << " could not be saved." << endl;
    }
    else
    {
        cout << filename << "Successfully saved!" << endl;
    }
}

// function to count numbers within a certain range.
int count(int x, int y)         // ((x >= 0)&&(x <= 24))
{
    int numOf = 0;              // variable counter
    int target;

    target = (( target >= x)&&(target <= y));

    for(int cntr = 0; cntr < students; cntr++)  
    {
        if(list[students] == target)
        {
            numOf += 1; // adds 1 for every number found between
        }                       // range target.
        return numOf;           // returns number of occurances found.
    }
}

```

The last function is where my problem lies, I'm not quite sure how to go about this. Any help would be wonderful!
-Chris-