Sorting Array in C++
Now my requirement is to sort 10 names from their with respect to their first character using bubble sort or any other sorting algorithm. I have my code here:
#include <iostream.h>
#include <conio.h>
#include <string.h>
main()
{
char name[10][25];
cout<<"Enter the Names:"<<endl;
//prompt user to input 10 names
for (int i = 0; i<=9; i++)
{
cout<<"Name"<<i+1<<": ";
cin>>name[i];
}
//display 10 names
for (int j=0;j<=9;j++)
{
cout<<name[j]<<endl;
}
getch();
}
MAXOOD!
Life is an endless journey towards perfection
__________________
MAXOOD!
Life is an endless journey towards perfection
|