Write A Program for sorting of n strings

#include<stdio.h> #include<conio.h> # include < string.h > void main ( ) { char str [20] [15],s[15]; int i...

#include<stdio.h>
#include<conio.h>
# include<string.h>
void main ( )
{
char str [20] [15],s[15];
int i,j,n;
printf (“enter how many strings”);         
scanf ( %d”, &n);
printf (“\n enter strings”);
For ( i =0; i < n, i++)
scanf ("%s” str [i]);
for ( i =0; i < n-1; i++)
{
for ( j = i +1; j < n; j++)
{
if (strcmp ( str [i], str [j]) >  0)
{
strcpy ( s, str [i]);
strcpy ( str [i], str [j]);
strcpy ( str [j], s);
 }
 }
 }
printf (“\n After sorting strings are \n”);
for ( i =0, i < n; i++)
printf (“\n %s”, str [i]);
getch ( );

}

Related

C Programs 5688778813190991887

Post a Comment

emo-but-icon

item