// output results
for ( int rating = 1; rating
<= 9; rating++ ) {
cout << setw( 8 ) << rating << setw( 11 )
<< freq[ rating ] << " ";
// keep track of mode value and largest
fequency value
if ( freq[ rating ] > largest )
{
largest = freq[ rating ];
modeValue = rating;
} // end if
// output histogram bar representing
frequency value
for ( int k = 1; k <= freq[ rating ]; k++ )
cout << '*';
cout << '\n'; // begin new line of output
} // end outer for
// display the mode value
cout << "The mode is the most
frequent value.\n"
<< "For this run the mode is
" << modeValue
<< "
which occurred " << largest << "
times." << endl;
} // end function mode