line 67: error C2665: 'swap' : none of the 3 overloads could convert all the argument types
c:\users\username\documents\cins121 cc++ programming\chapter 02 assignment\student
grade\student grade\source.cpp
#include <iostream>
#include <iomanip>
using namespace std;
void selectionSort ( double *, int );
void showArray( double *, int );
void showAverage ( double, int );
void swap ( double *, int );
int main()
{
double *scores;
double total = 0;
double average = 0;
int numScores;
//Get the number of test scores.
cout << "How many test scores will you enter?";
cin >> numScores;
//Dynamically allocate an array large enough to hold that many test scores
scores = new double[numScores];
for (int count = 0; count < numScores; count++)
{
cout << "Test score " << ( count + 1 ) << ": ";
cin >> scores[count];
}// end for
//Calculate the total scores
for (int count = 0; count < numScores; count++)
{
total += scores[count];
}
//sort the elements of the array
selectionSort ( scores, numScores );
cout << "\nThe test scores in decending order, and their average are:\n\n"
<< "Score\n-----\n";
showArray ( scores, numScores );
showAverage ( total, numScores );
system ("pause");
return 0;
}// end main
void selectionSort ( double *const array, const int size )
{
int largest;
// loop over size - 1 elements
for ( int i = 0; i < size - 1; i++ )
{
largest = i;
// loop to find the largest element
for ( int index = i + 1; index < size; index++ )
if ( &array[ i ], &array[ largest ] )
largest = index;
swap( &array[ i ], &array[ largest ] );
}// end if
}// end function select
void swap( double * const element1Ptr, double * const element2Ptr )
{
double hold = *element1Ptr;
*element1Ptr = *element2Ptr;
*element2Ptr = hold;
}// end function swap
void showArray(double *array, int size)
{
for (int count=0; count< size; count++)
cout << array[count] << " \n";
cout << endl;
}
void showAverage(double total, double numScores)
{
double average;
//Calculate the average
average = total / numScores;
//Display the results.
cout << fixed << showpoint << setprecision(2);
cout << "Average Score: " << average << endl;
}
Hello and ***thank*** you for any input you may provide in advance.

New Topic/Question
Reply


MultiQuote




|