Need help urgently!

I'm trying to create a program which takes in different memory sizes for an unknown number of files and:
(1) counts how many files there are
(2) the total memory used
(3) calculates the average size of these files.

I've tried my best with it and although the program works, the values for the second and third questions comes up as 0, so therefore doesn't work. I would appreciate any help and TIA! :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 #include <iostream>

using namespace std;

int main(int argc, const char * argv[])
{
    int fileSize[100];
    int count=0-1;
    
    // Asks user to enter file size value and repeats until user enters 0 to stop
    do {
        cout << "Please enter the file size. Enter 0 once all files have been entered to proceed.\n";
        cin >> fileSize[100];
        count++; // Counts the number of user inputs
    } while (fileSize[100] != 0);
    
    int memoryUsage=0;
    
    // Calculates the sum of the users input to display total memory usage
	for (int i=0; i<count; i++)
	{
		memoryUsage+=fileSize[i];
	}
    
    int average;
    
    // Calculates the average size by dividing the memory usage by the number of user inputs and assigs this value to the variable named average
    
    average = memoryUsage/count;
    
    cout << "There are " << count << " files.\n"; // Displays the number of files there are to the user
    cout << "The total memory used is " << memoryUsage << " MB.\n"; // Displays the total memory used to user
    cout << "The average memory size of these files is " << average << ".\n"; // Displays the average of the memory files sizes to user
    
    cin.get();
    return 0;
}
13
14
15
        cin >> fileSize[100];
        count++; // Counts the number of user inputs
    } while (fileSize[100] != 0);
fileSize[100] is out of bounds.
Topic archived. No new replies allowed.