Thursday, July 30, 2009

sorting string in alphabetical order

#include
#include
#include
void main()
{
char str[10],temp;
int i,n,j,c;
clrscr();

printf("Enter the string to be converted in alphabetical order:");
scanf("%s",str);
n=strlen(str);

for(i=0;str[i]!='\0';i++)
for(j=i+1;j {
if(str[i]>str[j])
{
temp=str[i];
str[i]=str[j];
str[j]=temp;
}
}
getch();

}

No comments:

Post a Comment