#include <iostream>
#include <string>
#include <iomanip>

using namespace std;
//Function prototypes declared before main function
void InputData(string playerNameAr[], int scoreAr[], int &numPlayersRef);
void DisplayPlayerData(const string playerNameAr[], const int scoreAr[], int numPlayers);
double CalculateAverageScore(const int scoreAr[], int numPlayers);
void DisplayBelowAverage(const string playerNameAr[], const int scoreAr[], int numPlayers, double averageScore);


// declaring variables
string playerNameAr[100];
double scoreAr[100];
int numPlayers = 0;
double averageScore;
const int arraySize = 100;



void main()
{
const string playerNameAr[100];
const double scoreAr[100];
int numPlayers = 0;
double averageScore;
	InputData(playerNameAr, scoreAr, numPlayers);
    DisplayPlayerData(playerNameAr, scoreAr, numPlayers);
    averageScore = CalculateAverageScore(scoreAr, numPlayers);
    DisplayBelowAverage(playerNameAr, scoreAr, numPlayers, averageScore);
}
// function definitions go here

// InputData Function

void InputData(string playerNameAr[], int scoreAr[], int &numPlayersRef)
{
	int numPlayers = 0;
	const int arraySize = 100;
	while (numPlayersRef < arraySize)
	{
		cout << "Enter Player Name (Q to quit): " << endl;
		getline(cin, playerNameAr[numPlayersRef]);
		if (playerNameAr[&numPlayerRef] == "Q")
			break;
		cout << "Enter score for " << playerNameAr[numPlayersRef] << ": ";
		cin >> scoreAr[numPlayersRef];
		numPlayersRef++;
	}
}

void DisplayPlayerData(const string playerNameAr[], const int scoreAr[], int numPlayers)		
{
	int i = 0;
	numPlayers = 0;

	for(i < numPlayers)
	{
	cout << playerNameAr[i] << scoreAr[i] << endl;
	i++;
	}
}

double CalculateAverageScore(const int scoreAr[], int numPlayers)
{
	int i;
	double averageScore, totalScore;
	for (i = 0, totalScore = 0; i < numPlayers; i++)
	{
		totalScore += scoreAr[i];
	averageScore = totalScore / numPlayers;
	cout << "Average Score: " << averageScore << endl << endl;
	return averageScore;
}

void DisplayBelowAverage(const string playerNameAr[], const int scoreAr[], int numPlayers, double averageScore)
{
	cout << "Players who scored below average ";
	cout << setw(10) << left << "  Name" << setw(5) << right << "Score" << endl;
	for(int i = 0; i < numPlayers; i++)
        if(scoreAr[i] < averageScore)
            cout << setw(10) << left << playerNameAr[i] << setw(5) << right << scoreAr[i] << endl;

}



}

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

Please use the code tags. There is still time to edit your post. Click on Edit underneath your name and put the code in [code] //code here [/code]. Also, what is your question?

This article has been dead for over six months. Start a new discussion instead.