98 965
Assignments Done
98.9%
Successfully Done
In May 2021

Answer to Question #44587 in C++ for Bull

Question #44587
write a function sort() to perform the sorting algorithm. But i don't know how to sort the names by alphabetical order. Thanks.

#include&lt;iostream&gt;
#include&lt;iomanip&gt;
#include&lt;string&gt;
using namespace std;
int main()
{
const int arraySize=20;
string name[arraySize]={&quot;John&quot;,&quot;Catherine&quot;,&quot;Shelly&quot;,&quot;Zane&quot;,&quot;Ben&quot;,&quot;Tom&quot;,&quot;Albert&quot;,&quot;Melly&quot;,&quot;Danny&quot;,&quot;Jane&quot;,&quot;Elsa&quot;,&quot;Fiona&quot;,&quot;George&quot;
&lt;&lt;&quot;Harry&quot;,&quot;Idina&quot;,&quot;Kelly&quot;,&quot;Lance&quot;,&quot;Nandos&quot;,&quot;Patrick&quot;,&quot;Rose&quot;};
int i,hold;

for(i=0;i&lt;arraySize;i++)
{
cout&lt;&lt;&quot; &quot;&lt;&lt;a[i];
}

for(int pass=0;pass&lt;arraySize-1;pass++)
{
for(i=0;i&lt;arraySize-1;i++)
{
if(a[i]&gt;a[i+1])
{
hold=a[i];
a[i]=a[i+1];
a[i+1]=hold;
}
}
}

for(i=0;i&lt;arraySize;i++)
{
cout&lt;&lt;&quot; &quot;&lt;&lt;a[i];
}

return 0;
}
1
2014-07-31T09:23:30-0400

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!