From 709b3e445dab2224aadf773d1f5608df6bd35dab Mon Sep 17 00:00:00 2001 From: simranpriya <62329455+simranpriya@users.noreply.github.com> Date: Sun, 25 Oct 2020 02:46:20 +0530 Subject: [PATCH] Create sort a string array in ascending order --- sort a string array in ascending order | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 sort a string array in ascending order diff --git a/sort a string array in ascending order b/sort a string array in ascending order new file mode 100644 index 0000000..75ad52a --- /dev/null +++ b/sort a string array in ascending order @@ -0,0 +1,25 @@ +#include +#include +void main() +{ + char str[100],ch; + int i,j,l; + + printf("\n\nSort a string array in ascending order :\n"); + printf("--------------------------------------------\n"); + printf("Input the string : "); + fgets(str, sizeof str, stdin); + l=strlen(str); + /* sorting process */ + for(i=1;istr[j+1]) + { + ch=str[j]; + str[j] = str[j+1]; + str[j+1]=ch; + } + printf("After sorting the string appears like : \n"); + printf("%s\n\n",str); + } +