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

Write A Program for calculating NCR using Functions

# include<stdio.h> #include<conio.h> void main ( ) { int n, r, ncr, a, b, c; clrscr( ) ; int fact ( int); printf (“enter n, r values”); scanf ("%d%d”, & n, & r); a = ...

Write A Program for calculating NCR value

# include<stdio.h> #include<conio.h> void main ( )           { int n, r, ncr, a, b, c, i; clrscr ( ) ; a = b = c = 1; printf ( “enter n, r values”); ...

Program for Insertion of an elementt into an array

# include<stdio.h> #include<conio.h> void main() { int a[10],i, j, n , pos , x ; printf ( “enter size of an array”); scanf ("%d", & n); printf ( “enter elements in to an arr...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item