#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main() {
   ifstream inFile ;
   int sales, counter=0 ;
   float average = 0.0;
   inFile.open("sales.dat", ios::in|ios::binary);
   	if (inFile.fail()){
	   cout << "Error !";
   	}
   inFile.read((char *)(&sales), sizeof(int));
   while (!inFile.eof()) {
        average += sales ;
        counter ++;
      inFile.read((char *)(&sales), sizeof(int));
   }
   inFile.close();
   average /= counter ;
   cout<<"average = "<<average;
   return 0;
}
