In this program I have to write a program that has to take the inputs of a file and output the average of the sum of numbers. My question is regarding how to average the numbers by adding the total numbers in the file. Would I have to do a count?

Code:

#include <fstream>#include <iostream>
int main()
{
using namespace std;
ifstream in_stream;
cout << "I am going to take the numbers from the input file and average them." << endl;
in_stream.open ( "input.dat" );
if ( in_stream.fail( ) )
{
cout << "Please check if the file is saved properly. It could not open." << endl;
}
double first_number, next_number, total_numbers;
int count = 0;
in_stream >> first_number >> next_number >> total_numbers;
first_number = 0;
next_number = first_number + next_number;
cout << "The average of the numbers is ";
cout << ( first_number + next_number ) / total_numbers << endl;
in_stream.close ();
cout << "The program will now close." << endl;
}