#include <iostream>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
    string names[10];
    int score[10];

    for(int scores = 0; scores < 10; scores++)
    {
        cout << "What is your score? ";
        cin >> score[scores];
        cout << endl;
    }


    int swapHolder = -1;
    int ten = 10;

    for(int counter = 9; counter >= 0; counter--)
    {
        for(int i = 0; i < 10; i++)
        {
            if(score[i] > score[i + 1])
            {
                swapHolder = score[i + 1];
                score[i + 1] = score[i];
                score[i] = swapHolder;
            }
        }
        ten--;
    }

    for(int i = 0; i < 10; i++)
    {
        cout << "Score: " << score[i] << endl;
    }

    system("pause");
    return 0;
}

How do I fix my Run time failure #2??

You don't explain what you mean by "runtime failure #2". Are you running this as a managed c++ application in C#? How did you compile it? What operating system is it running on? What compiler did you use?

You're overrunning the end of the array in the sorting algorithm. The inner loop should stop at 8 rather than 9, because inside the loop you're referencing the index at i + 1.

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.