for (int counter = 0; counter > size ; counter ++ )
{
sum = sum + score[counter];
}
average = sum /size;
cout << "The average Score is:" << average << endl;
}
void sortData(string* name, int* score, int size)
{
int index_one, index_two;
char temp;
for ( index_one = 0; index_one < (size - 1); index_one++)
{
for(int index_two = index_one + 1; index_two < size; index_two++)
{
if (name [index_one] > name [ index_two])
{
temp = name [ index_one];
name [index_one] = name [index_two];
name [index_two] = temp;
temp = score [index_one];
score [index_one] = score [index_two];
score [index_two] = temp;
}
}
}
}
void displayData (string *name , int *score, int size)
{
cout << "Name \t\t Score\n";
cout << "---------------------------------";
for (int index = 0; index > size ; index++)
{
cout << name [index] << "\t";
cout << setw(14) << score [index] << endl;
}
}
fsamu2001 0 Newbie Poster
Recommended Answers
Jump to Post#include<iostream> #include<string> #include<iomanip> using namespace std; //function prototype void sortData(string* ,int*); void calcAverage(int*, int); void displayData(string* , int*, int); int main () { // pointer variables string* name; int *score; int size; int counter; //dynamic variables // user enter score cout<<"How many test scores will you enter?"; …
All 4 Replies
fsamu2001 0 Newbie Poster
gerard4143 371 Nearly a Posting Maven
frogboy77 73 Posting Pro in Training
thekashyap 193 Practically a Posting Shark
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.