Algorithm:
1. Start
2. define str[10][20], temp[20]
3. For i=0, increment i and iterate to i<10, taking input str[i]
4. For i=0, increment i and iterate to i<n and go to step 5
5. For j=0, increment i and iterate to i<9-i, go to step 6
6. if strcmp(str[j],str[j+1]) > 0, go to step 7
7. strcpy(temp, str[j])
8. strcpy(str[j],str[j+1])
9. strcpy(str[j+1],temp)
10. For i=0, increment i and iterate to i<n, print str[i]
11. Stop
Code:
#include<stdio.h>#include<string.h>int main(){char str[10][20], temp[20];printf("Enter any 10 words to sort: \n");for(int i=0;i<10;i++){scanf("%s",str[i]);}for(int i=0;i<10;i++){for(int j=0;j<9-i;j++){int flag = strcmp(str[j],str[j+1]);if(flag>0){strcpy(temp,str[j]);strcpy(str[j],str[j+1]);strcpy(str[j+1],temp);}}}for(int i=0;i<10;i++){printf("%s ",str[i]);}printf("\n");}{codeBox}
This is the C Program to arrange an array of strings in dictionary order iterating over every string and comparing and swapping in dictionary order.