i have a problem getting it to display the average score of the players entered and also the player names and their scores for those that scored below the average. it works other than that. its late, ive been at this and another program for hours im probably not thinking straight anymore. any help would be great
#include <iostream>
#include<string>
#include<iomanip>
using namespace std;
int inputData(char[][50], int[], int&, int&);
int displayData(char[][50], int[], int);
int main()
{
char playerName[100][50] = {0};
int score[100] = {0};
int average;
int belowAverage = 0;
int numPlayers = 0;
inputData(playerName, score, numPlayers, average);
displayData(playerName, score, numPlayers);
cout << "\n\nAverage Score: " << average << endl;
cout << "\n\nPlayers who scored below the average: " << belowAverage << endl;
}
int inputData(char playerName[][50], int score[100], int &numPlayers, int &average)
{
while(numPlayers < 100)
{
cout <<" Enter Players Name(Q to quit) :";
cin >> playerName[numPlayers];
if(playerName[numPlayers][0] == 'q' || playerName[numPlayers][0] == 'Q')
break;
cout << "Enter score:";
cin >> score[numPlayers];
numPlayers += 1;
average += score[numPlayers];
}
int belowAverage[50] = {0};
average = average / numPlayers;
for(int i = 0; i < average; i++)
{
belowAverage[i]= average;
}
if(score[numPlayers] < average)
score = belowAverage;
return 0;
}
int displayData(char playerName[][50], int score[100], int numPlayers)
{
for(int index = 0; index < numPlayers; index++)
{
cout << "\nPlayer Name: " << playerName[index] << endl;
cout << "Score: " << score[index] << endl;
}
return 0;
}