0
Help me
Can someone help me with my code #c++
10 Answers
+ 1
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
using namespace std;
int calculateAverageScores(int scores[],int size);
void displayPlayerData(string playerNames[],int scores[], int size);
int calculateAverageScores(int scores[],int size);
int inputData(string playerNames[], int scores[],int size)
{
int i;
for(int i=0;i<size;i++)
{ cout << "Enter Player Name: ";
getline(cin,playerNames[i]);}
cout << "Enter score for " << playerNames[i] << ": ";
cin >> scores[i];
cin.ignore();}
return i;}
void displayPlayerData(string playerNames[],int scores[], int size)
for (int i=0;i<size;i++)
{ cout << playerNames[i] << "\t" << scores[i] << endl;} }
int calculateAverageScores(int scores[],int size)
{ int i;
int totalScore=0, averageScore=0;
for(int i=0;i<size;i++)
{ totalScore= (totalScore+scores[i]);}
averageScore=totalScore/size;
cout << "Average Score: " << averageScore;
return i;}
int main()
{ int x;
//Latifah AlGhanem, Reema AlOumi, Yara AlHussaini//
do { cout<<"this program will calculate the avrage of the game score";
string playerNames[100];
int scores[100];
int sizeOfArray=sizeof(scores);
int sizeOfEachElement=sizeof(scores[0]);
int numberOfElements=sizeOfArray/sizeOfEachElement;
cout << numberOfElements<< endl;
int numberEntered=inputData(playerNames,scores,numberOfElements);
displayPlayerData(playerNames,scores,numberEntered);
cin.ignore();
cin.get();
cout<<"if you want to stop please enter '0'"<<endl;
cin>>x;}
while ( x!=0);
}
displayPlayerData( playerNames[],scores[], size)
cout<<calculateAverageScores<<endl;
+ 1
i will try upto basics
+ 1
i see you code..
what is problem come tell us also..
if you talking about error..
you only forgot to apply parenthesis .
or in logic..
https://code.sololearn.com/cB9wjy11WcEU/?ref=app
i try to
0
Oky can you contact me on WhatsApp
0
Post your code here. You'll get more help.
0
Okay I will post it
0
Okay I will post it
0
I want to write a code With function and arrays about game system
0
H
0
Can I have your email to explain the code to you please me