Embed presentation
Download to read offline
![#include <stdio.h>
#include <string.h>
int main()
{
char name[20][10], tname[20][10], temp[10];
int i, j, n;
printf("Enter the number of Names you want to do input:n"); //how many names input
scanf("%d", &n);
printf("Enter names: n");
for (i = 0; i < n; i++)
{
scanf("%s", name[i]);
strcpy(tname[i], name[i]);
} //input names
for (i = 0; i < n - 1 ; i++)
{
for (j = i + 1; j < n; j++)
{
if (strcmp(name[i], name[j]) > 0)
{ strcpy(temp, name[i]);
strcpy(name[i], name[j]);
strcpy(name[j], temp);
}
}
} //for alphabetically sorting](https://image.slidesharecdn.com/programtosortthennamesinanalphabeticalorder-161130182735/75/Program-to-sort-the-n-names-in-an-alphabetical-order-1-2048.jpg)
![printf("n----------------------------------------n");
printf(" Input || NamestSorted namesn");
printf("------------------------------------------n");
for (i = 0; i < n; i++)
{
printf("%st || t%sn", tname[i], name[i]); //printf storted names
}
printf("------------------------------------------n");
}
By Samsil Arefin
Samsilarefin017@gmail.com](https://image.slidesharecdn.com/programtosortthennamesinanalphabeticalorder-161130182735/85/Program-to-sort-the-n-names-in-an-alphabetical-order-2-320.jpg)

The document is a C program that takes a user-defined number of names as input and sorts them alphabetically. It uses string manipulation functions to compare and rearrange the names. The program then displays the original and sorted names in a structured format.
![#include <stdio.h>
#include <string.h>
int main()
{
char name[20][10], tname[20][10], temp[10];
int i, j, n;
printf("Enter the number of Names you want to do input:n"); //how many names input
scanf("%d", &n);
printf("Enter names: n");
for (i = 0; i < n; i++)
{
scanf("%s", name[i]);
strcpy(tname[i], name[i]);
} //input names
for (i = 0; i < n - 1 ; i++)
{
for (j = i + 1; j < n; j++)
{
if (strcmp(name[i], name[j]) > 0)
{ strcpy(temp, name[i]);
strcpy(name[i], name[j]);
strcpy(name[j], temp);
}
}
} //for alphabetically sorting](https://image.slidesharecdn.com/programtosortthennamesinanalphabeticalorder-161130182735/75/Program-to-sort-the-n-names-in-an-alphabetical-order-1-2048.jpg)
![printf("n----------------------------------------n");
printf(" Input || NamestSorted namesn");
printf("------------------------------------------n");
for (i = 0; i < n; i++)
{
printf("%st || t%sn", tname[i], name[i]); //printf storted names
}
printf("------------------------------------------n");
}
By Samsil Arefin
Samsilarefin017@gmail.com](https://image.slidesharecdn.com/programtosortthennamesinanalphabeticalorder-161130182735/85/Program-to-sort-the-n-names-in-an-alphabetical-order-2-320.jpg)