Code:
#include<iostream>
#include<iomanip>
using namespace std;
void prompt();
main()
{
cout.setf(ios::fixed, ios::floatfield);
cout.setf(ios::showpoint);
cout.precision(2);
int score=0;
int total=0;
int count=0;
int sentinel=-1;
while (score!=sentinel)
{
prompt();
cin >> score;
if (score!=sentinel)
{
total=total+score;
count=count+1;
}
}
if (count > 0)
cout << "The average is: "
<< (double)total/(double)count << endl;
else
cout << "No genuine scores were entered"<< endl;
return 0;
}
void prompt ()
{
cout << "Enter a number: ";
}