Can Somebody Explain this to me???
Code:#include <iostream> #include <iomanip> using namespace std; int main() { const int NUM_QUIZZES = 3; int grade[NUM_QUIZZES]; //The array to store the quiz grades int quiz, // Subscript for the array grade[] temp, // For swapping array elements pass, // The number of the pass limit; // Keeps track of how far to go on a pass // Get the grades cout << "Please enter " << NUM_QUIZZES << " integer quiz grades." << endl << endl; for (quiz = 0; quiz < NUM_QUIZZES; ++quiz) { cout << endl; cout << "Enter grade for quiz " << quiz + 1 << ": "; cin >> grade[quiz]; } // Display the quiz grades cout << endl << endl; cout << "The grades you entered are as follows:" << endl; for (quiz = 0; quiz < NUM_QUIZZES; ++quiz) cout << setw(6) << grade[quiz]; cout << endl; // Do the bubble sort limit = NUM_QUIZZES - 2; for (pass = 1; pass <= NUM_QUIZZES - 1; ++pass) { cout<<"Pass: "<<pass<<endl;//1//2 for (quiz = 0; quiz <= limit; ++quiz) if (grade[quiz] > grade[quiz + 1]) { temp = grade[quiz]; grade[quiz] = grade[quiz + 1]; grade[quiz + 1] = temp; } limit; } // Display the sorted quiz grades cout << endl << endl; cout << "The grades in increasing order are as follows:" << endl; for (quiz = 0; quiz < NUM_QUIZZES; ++quiz) cout << setw(6) << grade[quiz]; cout << endl; return 0; }
why "num-quizzes minus 2", and why the "limit;" and why the "num quiz -1", under the do bubble sort comment????



LinkBack URL
About LinkBacks



