A C program for sorting of strings alphabetically.
void main() { int i,j,n; char s[5][20],t[20]; printf("\n Enter any 5 strings separated by enter:"); for(i=0;i<5;i++) //Taking input strings { scanf("%s",s[i]); } for(i=1;i<5;i++) // Logic to sort the strings alphabetiaclly { for(j=1;j<5;j++) { if( strcmp( s[j-1] , s[j] ) > 0) { strcpy( t,s[j-1] ); strcpy( s[j-1] , s[j] ); strcpy( s[j] , t); } } } printf("\n The Strings in the order:"); for(i=0;i<5;i++) // Display the strings { printf("\n %s \n",s[i]); } }