Hi I'm new to c++ programming. This is my first ever program, it calculates the average of numbers that the user input. The user can input up until 10 numbers. I get a segmentation fault for some reason. Any ideas?
#include<iostream>
using namespace std;
int main()
{
int numbers[10]; // array could have up until 10 numbers.
int sum = 0; // intial sum.
int count = 0; // initial count.
int average; // Average.
int i; // input
while (cin >> numbers[i])
{
i++;
sum = sum + numbers[i];
count = count +1;
}
average = sum/count;
cout <<average<< endl;
}