#include<stdio.h>
#include<conio.h>
void main()
{
char name[10][20],temp[20];
int i,j,n;
printf("how many string you want to enter\n");
scanf("%d",&n);
printf("enter the strings\n");
for(i=0;i<=n;i++)
{
gets(name[i]);
strlwr(name[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if((strcmp(name[j],name[j+1])==1))
{
strcpy(temp,name[j]);
strcpy(name[j],name[j+1]);
strcpy(name[j+1],temp);
}
}
}
printf("sorted form of data are:\n");
for(i=0;i<=n;i++)
{
printf("%s\n",name[i]);
}
}
#include<conio.h>
void main()
{
char name[10][20],temp[20];
int i,j,n;
printf("how many string you want to enter\n");
scanf("%d",&n);
printf("enter the strings\n");
for(i=0;i<=n;i++)
{
gets(name[i]);
strlwr(name[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if((strcmp(name[j],name[j+1])==1))
{
strcpy(temp,name[j]);
strcpy(name[j],name[j+1]);
strcpy(name[j+1],temp);
}
}
}
printf("sorted form of data are:\n");
for(i=0;i<=n;i++)
{
printf("%s\n",name[i]);
}
}
No comments:
Post a Comment