/* 13(b) W.A.P. to accept 10 names and sort them in ascending order. */

#include<stdio.h>
#include<string.h>
void main()
{
    char str[25][8],dummy[8]; /* Variable Declarations */
    int i,j,n;
    clrscr();
    printf("How many names are there : ");
    scanf("%d",&n);
    printf("\n\nEnter names (Max. 8 Characters) :\n");
    for (i=0; i<n; i++)
    {
        printf("Name %d = ",i+1);
        scanf("%s",&str[i]);
    }
    /* Sorting the names in alphabetical order using Bubble Sort Technique */
    for (i=0; i<n; i++)
    {
        for (j=1; j<(n-i); j++)
        {
            if (strcmp(str[j-1],str[j])>0)
            {
                strcpy(dummy,str[j-1]);
                strcpy(str[j-1],str[j]);
                strcpy(str[j],dummy);
            }
        }
    }
    printf("\n\nThe names in alphabetical order are as follows :\n");
    for (i=0; i<n; i++)
    {
        printf("%s\n",str[i]);
    }
    getch();
}