netoops blog

Sunday, 25 August 2013

String Sorting

#include<stdio.h>
#include<conio.h>
#include<string.h>


void main()
{
char *names[] = {
  "Sanjukta",
  "Arindam",
  "Chandan",
  "Arnab",
  "Shivaji"
     };
int i,j,d;
char *t;
clrscr();
for (i=0;i<=4;i++)
printf ("\n%s",names[i]);

     for (i=0;i<=3;i++)
{
for (j=i+1;j<=4;j++)
{
d = strcmp(names[i],names[j]);
if (d>0)
{
t = names[i];
names[i] = names[j];
names[j] = t;
}
}
}
printf ("\n\n\n");
for (i=0;i<=4;i++)
printf ("\n%s", names[i]);
getch();
}

Tech Knowledege
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments :

Post a Comment

 
Subscribe For Free Updates!

We'll not spam mate! We promise.

Become Our Fan on Social Sites!