I have two arrays. One is of roll numbers, the other is of total marks for the roll numbers. I have to sort the roll number array in ascending order while keeping the data as it is assigned to each roll number. I have sorted the array but how do I put the marks accordingly to the roll number?
Here's the code so far.
int roll_num[5] = { 2, 4, 1, 6, 8 }, total_marks[5] = { 9, 7, 10, 8, 9 }, min=0, temp, size = 5;
    for (int i = 0; i <= size; i++)
    {
        min = i;
        for (int j = i + 1; j < size; j++)
        {
            if (roll_num[j] < roll_num[min])
            {
                min = j;
            }
        }
        swap(roll_num[i], roll_num[min]);
    }
    cout << "Roll No." << " " << "Total Marks" << endl;
    for (int i = 0; i < size; i++)
    {
        cout << roll_num[i] << "       |     " << total_marks[i] << endl;
    }