View Single Post
  #1 (permalink)  
Old May 17th, 2008, 02:11 PM
code_lover code_lover is offline
Authorized User
 
Join Date: Jan 2007
Posts: 46
Thanks: 2
Thanked 1 Time in 1 Post
Default 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
Reply With Quote