hello i am working on demonstrating input and output of files. I am getting an error prompt when attempting to run the attached code, without it showing any errors:
int number;
int sum = 0;
double average = 0;
ifstream inputFile; //input numbers from data.txt
inputFile.open("data.txt");
if (inputFile) { //if the file opens
while (inputFile >> number) {
sum = sum + number;
}//end of while statement
average = sum / 20.0;
}//end of if statement
else { //filename wrong or nonexistent
cout << "File Does not Exist" << endl;
}//end of else statement
inputFile.close();
ofstream outputFile;
outputFile.open("results.txt");
outputFile << "The number of values is 20." << endl;
outputFile << "The sum of the numbers is: " << sum << endl;
outputFile << "The aveage of the numbers is: " << average << endl;
outputFile.close();
return 0;