1. ## Drop lowest score?

What code can i use to drop the lowest score and average it out?
Code:
```#include <iostream>
#include <iomanip>
using namespace std;

const int SIZE = 5, LENGTH = 25, SCORES = 4;

void getNames(char [][LENGTH]);
void getScores(char [][LENGTH], char [], double [][SCORES]);
void display(char [][LENGTH], char [], double [][SCORES]);

int main()
{
char students[SIZE][LENGTH];
double score[SIZE][SCORES];

getNames(students);
system("pause");
return 0;
}

void getNames(char students[][LENGTH])
{
for(int i = 0; i < SIZE; i++)
{
cout << "Please enter student " << (i+1) << " name: ";
cin.getline(students[i],LENGTH);
}
}

void getScores(char students[][LENGTH], char grade[], double score[][SCORES])
{
int avg = 0;

for(int i = 0; i < SIZE; i++)
{

for(int j = 0; j < SCORES; j++)
{
cout << (j+1) << ": ";
cin >> score[i][j];
avg += score[i][j];
}

avg = avg / SCORES;

if(avg > 89)
else if(avg > 79)
else if(avg > 69)
else if(avg > 59)
else
}

}

void display(char s[][LENGTH], char g[], double sc[][SCORES])
{
int avg = 0;

for(int i = 0; i < SIZE; i++)
{
cout << s[i] << endl;

for(int j = 0; j < SCORES; j++)
{
cout << sc[i][j] << endl;
avg += sc[i][j];
}

cout << g[i] << endl;
}
}```

Your teacher should have taught you an if statement by now. If not it looks like this
Code:
```if(condition)
{
dosomething();
}```
So you see if the score is lowest using operators

< (less than)
> (greater than)
== (equal to)
<= (lessthan or equal to)
>= (greater than or equal to)

Those are your tools you know you got this.

3. Use std::sort() to sort from lowest to highest, then use std::accumulate() on all the scores except the first one, then divide by the number of scores - 1.

4. Originally Posted by cpjust
Use std::sort() to sort from lowest to highest, then use std::accumulate() on all the scores except the first one, then divide by the number of scores - 1.
std::sort would be overkill. It would suffice to use std::min_element to find the lowest score, then swap it with the last score, and then use std::accumulate on all the scores except the last one, then divide by the number of scores - 1.

5. Originally Posted by laserlight
std::sort would be overkill. It would suffice to use std::min_element to find the lowest score, then swap it with the last score, and then use std::accumulate on all the scores except the last one, then divide by the number of scores - 1.
Yeah, that would definitely be better.