| Close | Back |
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#include<rajesh.h>
main()
{
char name[10][20],temp[20];
int i,j,n;
clrscr();
do
{
printf("\nEnter the number of names you want to enter (Below 10)\t");
scanf("%d",&n);
}
while(n<=0 || n>10);
printf("\nEnter the name\n");
for(i=0;i<n;i++)
{
scanf("%s",name[i]);
}
for(i=0;i<n;i++)
for(j=0;j<n-1;j++)
if(strcmpi(name[j],name[j+1]) > 0)
{
strcpy(temp,name[j]);
strcpy(name[j],name[j+1]);
strcpy(name[j+1],temp);
}
printf("\nThe sorted array of names is\n");
for(i=0;i<n;i++)
printf("%s\n",name[i]);
getch();
}