Please I need help with thisPlease also provide comments in
Please I need help with this....Please also provide comments in each line and a successful output screenshot.
Lanuage: C++
******************************************************************************************
Create an array of strings: Names.
Initialize forwardOrderNames with: “Fred”, “Tuyet”, “Annie”, “Moe”, “Ria”, “Luke”, “Jim”, “May”, ”Rex”, ”Omar”.
Add this Bubble sort code, AND run the code and print the array again. Explain how it works.
string tmp;
 for( i=1; i
for( j=4; j>=i; --j)
 if (strcmp(forwardOrderNames [j-1], forwardOrderNames [j])>0) {
tmp = forwardOrderNames [j-1]; forwardOrderNames [j-1] = forwardOrderNames [j]; forwardOrderNames [j] = tmp;
} }
Solution
#include <iostream>
 #include<string>
using namespace std;
int main()
 {
 int i,j;
 string forwardOrderNames[]= {\"Fred\", \"Tuyet\", \"Annie\", \"Moe\", \"Ria\", \"Luke\", \"Jim\", \"May\", \"Rex\", \"Omar\"};
 string tmp;
 for( i=0; i<10; i++)
 {
 for( j=1; j<10; j++)
 if (forwardOrderNames [j-1]> forwardOrderNames [j])
 {
 tmp = forwardOrderNames [j-1];
 forwardOrderNames [j-1] = forwardOrderNames [j];
 forwardOrderNames [j] = tmp;
 }
 }
for( i=1; i<10; i++)
 cout << \" \" <<forwardOrderNames[i];
 return 0;
 }
OUTPUT:
Fred Jim Luke May Moe Omar Rex Ria Tuyet

