Remember to checkout the Codesnip below to review the C++ code yourself! Feel free to copy the code, but I ask that you please provide credit if you leave the code unchanged when you use it.
//Name: Nazmus //Program: Index Sort //Website: EasyProgramming.net #include <iostream> #include <string> using namespace std; int main() { string name[7]; int grade[7]; int index[7]; int i, j; for(i=0;i<=6;i++) { cout << "Please enter name: "; cin >> name[i]; cout << "Please enter grade: "; cin >> grade[i]; } for(i=0;i<=6;i++) { index[i]=i; } for(i=0;i<=5;i++) { for(j=i+1;j<=6;j++) { int temp; if(name[index[i]] > name[index[j]]) { temp = index[i]; index[i] = index[j]; index[j] = temp; } } } cout << endl; for(i=0;i<=6;i++) { cout << name[index[i]] << " " << grade[index[i]] << endl; } cin.ignore(); cin.get(); //system("pause"); }