/* Sort array of 10 strings. */ #include<string.h> #include<stdio.h> int main() { int i,j; char str[10][10],temp[10]; printf("Type 10 names :\n"); for(i=0;i<10;i++) { // gets(str[i]); // fgets is a better option over gets to read multiword string . fgets(str[i], 10, stdin); } for(i=0;i<10;i++) { for(j=0;j<10-1-i;j++) { if(strcmpi(str[j],str[j+1])>0) { strcpy(temp,str[j]); strcpy(str[j],str[j+1]); strcpy(str[j+1],temp); } } } printf("\nSorted Names :\n"); for(i=0;i<10;i++) puts(str[i]); return 0; }
Sort array of 10 strings
Subscribe to:
Post Comments (Atom)
This comment has been removed by the author.
ReplyDeleteinformative blog , keep posting and if you are intresting in code developer then checkout python classes in satara
ReplyDelete