//Sort an array of 3 names #include #include using namespace std; void swap(string &n1, string &n2) //receive strings n1 and n2, exchange { string temp; temp=n1; n1=n2; n2=temp; } //swap void main() //input 3 names, sort, print { string names[3]; //3 names: [0],[1],[2] int index; for(index=0; index<3; index++) { cout<<"enter a name: "; getline(cin,names[index]); } //for loop if (names[0]>names[1]) swap(names[0],names[1]); if (names[1]>names[2]) swap(names[1],names[2]); if (names[0]>names[1]) swap(names[0],names[1]); for(index=0; index<3; index++) cout<