Reading int values from an array and determining what range they fall between

I'm having some trouble with my programming exercise. I have to read integers from a text file and store them in an array. Then determine the number of integers that fall between the range 0-50, 50-55, all the way to 100.

Here's the code I currently have. I'm stuck on how to determine the range of the numbers. Any help would be appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <fstream>
using namespace std;
int countNum(int[], int);
int main()
{
    int arraySize = 50;
    char array[arraySize];
    int position = 0;
    
    ifstream fin("file.txt");
        while(!fin.eof() && position < arraySize)
        {
            fin.get(array[position]);
            position++;
        }
        array[position-1] = '\0';
        for(int i = 0; array[i] != '\0'; i++)
        {
            cout << array[i];
        }
Last edited on
I don't understand how you learned about file I/O before learning about if statements?

http://www.cplusplus.com/doc/tutorial/control/
Last edited on
Topic archived. No new replies allowed.