Thursday, September 20, 2012

program for string sorting

#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char a[20],b[20],t;
int n,j,i,r;
clrscr();
printf("Enter the string\n");
gets(a);
n=strlen(a);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
 }
}
printf("After sorting\n");
puts(a);



getch();
}

No comments:

Post a Comment