Question: #include #include #include int main() { std::string filename; std::cout std::cin >> filename; std::cout std::ifstream file(filename); if (!file.is_open()) { std::cout return 1; } int min =



#include
#include
#include
int main() {
std::string filename;
std::cout
std::cin >> filename;
std::cout
std::ifstream file(filename);
if (!file.is_open()) {
std::cout
return 1;
}
int min = INT_MAX, max = INT_MIN, count = 0, sum = 0, num;
while (file >> num) {
count++;
sum += num;
if (num
min = num;
}
if (num > max) {
max = num;
}
}
file.close();
double average = (double)sum / count;
std::cout
std::cout
std::cout
std::cout
std::cout
std::cout
return 0;
}
Please help fix
Write a C++ program that will: 1. Ask the user for the name of a data file. echo print the file name 2. open the data file - if the file fails to open print an error message and return to step 1 3. read an unknown number of integers from the file stop reading when you have reached the end of the file 4. report the Min, Max, Sum, Count, and Average of the data (round output Contents [hide] 1 Sample Run 2 Sample Input Data File 3 Documentation 4 Comments for Code Sections Sample Run [edit] Enter Data File Name: progila.txt min=10 Max=92 Sum =1284 Count =21 Average =61.14 COMPILE ERROR Or WARNING
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
