#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char c[10][20],temp[20];
int i,j,n;
clrscr();
printf("\nEnter number of strings:
");
scanf("%d",&n);
printf("\nEnter the strings: ");
for(i=0;i<=n;i++)
{
gets(c[i]);
}
puts(c[i]);
for(i=0;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
if(strcmp(c[i],c[j])>0)
{
strcpy(temp,c[i]);
strcpy(c[i],c[j]);
strcpy(c[j],temp);
}
}
}
printf("\nSorted list is:\n");
for(i=0;i<=n;i++)
printf("\n%s",c[i]);
getch();
}
//OUTPUT:
//Enter the
number of strings: 3
//Enter the
strings: VINIT
//RAVI
//SURAJ
//Sorted list is:
RAVI
//SURAJ
//VINIT
thnx
ReplyDeleteWhy did you declare c as a two dimensional array?
ReplyDeleteHow to get longest name same problem
ReplyDeleteYou have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site.
ReplyDeleteShedstorecabintours.review