Member Avatar for dvspinay

Here is my initial code. It is linking, but giving me an error code that I can't comprehend. I have to basically write a program to do the following:
In main declare a Player Name array and a score array. Declare the size of the arrays to be 100. In the inputData function input the player name and score into the arrays for an unknown number of players up to 100. In the DisplayPlayerData function display the name and score of each player. In the calculateAverageScore function calculate the average score and return it by value. In the displayBelowAverage function display the name of the player and score for any player who score below the average. Do not use global variables.

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

using namespace std;

int inputData(string[],int[],int &);
int displayPlayerData(string[], int[], int);
int calculateAverageScore(int[], int);
int displayBelowAverage(string[], int[], int, int);

int main()
{
 string playerName [100];
 int scores [100];
 int numberOfPlayers = 0;
 int averageScore = 0;

 inputData(playerName, scores, numberOfPlayers);
 displayPlayerData(playerName, scores, numberOfPlayers);
 averageScore = calculateAverageScore(scores, numberOfPlayers);
 displayBelowAverage(playerName, scores, averageScore, numberOfPlayers);
 system("pause");
 return 0;

 for (int x = 0; x < 100; x++)
  {
  cout << "Enter Player Name (Q to quit): ";
  getline(cin,(playerName)[x]);

  if (playerName[x] == "q"||playerName[x] == "Q")
  {
   break;
  }
  else cout << "Enter score for " <<playerName[x] <<": ";
  cin >> scores[x];
  cin.ignore();
  numberOfPlayers++; 
  }
 return 0;
}
int displayPlayerData(string playerName[], int scores[], int numberOfPlayers)
{
 cout << "\n\nName       Score" << endl;

 for (int x = 0; x < numberOfPlayers; x++)
  cout << setprecision(2) << fixed << left << setw(10) << playerName[x] << setw(10) << right << scores[x] << endl;
 return 0;
}
int calculateAverageScore(int scores[],int numberOfPlayers)
{
 int sum = 0;
 int avg = 0;

 for (int x = 0;x < numberOfPlayers; x++)
  sum += scores[x];
 avg = (sum / numberOfPlayers);
 cout << setprecision(2) << fixed << "Average Score: " << avg << endl;
 return avg;
}
int displayBelowAverage(string playerName[], int scores[], int averageScore,int numberOfPlayers)
{
 cout << "Players who scored below average:" <<endl;
 cout << "Name        Score" << endl;

 for (int x = 0; x < numberOfPlayers; x++)
  if (scores[x] < averageScore)
   cout << setprecision(2) << fixed << left << setw(10) << playerName[x] << setw(10) << right << scores[x] << endl;
  else continue;
  
 return 0;
}
1>------ Build started: Project: LAB5A, Configuration: Debug Win32 ------
1>Compiling...
1>LAB5A.cpp
1>Linking...
1>LAB5A.obj : error LNK2019: unresolved external symbol "int __cdecl inputData(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * const,int * const,int &)" (?inputData@@YAHQAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAHAAH@Z) referenced in function _main
1>\\ilabss\home$\D01192770\Documents\Visual Studio 2008\Projects\LAB5A\Debug\LAB5A.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://\\ilabss\home$\D01192770\Documents\Visual Studio 2008\Projects\LAB5A\LAB5A\Debug\BuildLog.htm"
1>LAB5A - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

>> unresolved external symbol "int __cdecl inputData(class std::basic_string<char

That means you declared and called a function named inputData() but never coded the body of that function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.