hey there, im new on C++ and have to do an assignment where i have to display names of soccer players and the number of goals and cards received. im busy with my first function, and if someone can help me i would realy apreciate it.
//question 1 assignment 4
#include <iostream>
using namespace std;
void inputinformation(int& goals)
{ for (int i =1;i <= 12; i++)
{ cout << " Enter the number of goals scored by the player : ";
cin >> goals;
}
}
int main ()
{ const int NR_PLAYERS = 12;
string names[ ] = {"Tiny Nakedi" , "Cecil Mametsa" , "Chris Rooney" , "Mario Thomas" , "Frank Ntini" , "Charlie Ashley",
"Morio Zondo" , "Khabo Mosimane" , "Pitso Hack" , "Lloyd Mokoena" , "Rick Smith" , "Kabelo Ramago"};
int goals;
int cards;
string namesMore;
cout << names[goals] << endl;
inputinformation(goals);
return 0;
}
the output :
Tiny Nakedi
Enter the number of goals scored by the player : 3
Enter the number of goals scored by the player : 4
Enter the number of goals scored by the player : 3
it must show the players name on each line for the goals. here it only shows the first one.
im first trying to figure out just putting in the goals. what am i doing wrong :)
thank you in advance. hope someone helps me quick :)