Suppose that a text file text.txt contains an unspecified number of scores. Write a program that reads the scores from the file and displays their total and average. Scores are separated by blanks.
What will be an ideal response?
```
#include
#include
using namespace std;
int main()
{
ifstream input;
// Open a file
input.open("Exercise13_1.txt");
if (input.fail())
{
cout << "File does not exist" << endl;
cout << "Exit program" << endl;
return 0;
}
int number = 0;
int total = 0;
while (!input.eof()) // Continue if not end of file
{
input >> number;
total += number;
}
input.close();
cout << "total is " << total << endl;
return 0;
}
```
You might also like to view...
What does “pass by value” mean?
What will be an ideal response?
should be used to prefix all Button names.
a) but b) lbl c) Frm d) btn
To make sure that a user can only pick from an item on the list in a Combo Box, the ________ to List property must be enabled
Fill in the blank(s) with correct word
Class diagrams are the software requirements specifications for each module in an application.
Answer the following statement true (T) or false (F)