My code seems to be working, I know that the user input is correctly adding to the arrays, but when I compile i'm getting errors in main, "expected primary expression before..." Any advice would be great because I'm very new to C++.
//The purpose of this program is to allow the user to input five names and five associated scores.
//The program should then print the list of top scorers on the screen in decending order.
#include <iomanip>
#include <iostream>
usingnamespace std;
constint size = 25;
char names[5][size];
int scores[size];
//This function should receive user input and pass the information along to the next function.
void initializeArrays(string names[],int scores[], int size) {
cout << "Enter the name for score #1: ";
cin >> names[0];
cout << "Enter the score for score #1: ";
cin >> scores[0];
cout << "Enter the name for score #2: ";
cin >> names[1];
cout << "Enter the score for score #2: ";
cin >> scores[1];
cout << "Enter the name for score #3: ";
cin >> names[2];
cout << "Enter the score for score #3: ";
cin >> scores[2];
cout << "Enter the name for score #4: ";
cin >> names[3];
cout << "Enter the score for score #4: ";
cin >> scores[3];
cout << "Enter the name for score #5: ";
cin >> names[4];
cout << "Enter the score for score #5: ";
cin >> scores[4];
}
//This function should take the under input for the two arrays from the previous
//function and sort the data in decending order
void sortData(string names[], int scores[], int size)
{
bool swap;
int temp;
do
{
swap = false;
for (int count = 0; count < (size - 1); count++)
{
if (scores[count] > scores[count + 1])
{
temp = scores[count];
scores[count] = scores[count + 1];
scores[count + 1] = temp;
swap = true;
}
}
} while (swap);
}
//This functon should receive the sorted arrays from the previous function
//and display the top scorers in decending order
int displayData(const string names[], constint scores[], int size) {
cout << "Top scorers: " << endl;
return 0;
}
int main () {
initializeArrays (string names[], int scores[], int size);
sortData(string names[], int scores[], int size);
displayData(const string names[], constint scores[],int size);
return 0;
}