Sep 30, 2011

C Program To Sort Names

Write a C program to read N names, store them in the form of an array and sort them in alphabetical order.Output the given names and the sorted names in two columns side by side with suitable heading.Program will sort the name strings using Bubble Sort technique. Read more about C Programming Language .

* You can use all the programs on
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact
* To find more C programs, do visit
* and browse!
*                        Happy Coding

#include <stdio.h>
#include <conio.h>
#include <string.h>

void main()
 char name[10][8], Tname[10][8], temp[8];
 int i, j, N;


 printf("Enter the value of N\n");
 scanf("%d", &N);

 printf("Enter %d names\n", N);
 for(i=0; i< N ; i++)
  strcpy (Tname[i], name[i]);

 for(i=0; i < N-1 ; i++)
  for(j=i+1; j< N; j++)
   if(strcmpi(name[i],name[j]) > 0)

 printf("Input Names\tSorted names\n");
 for(i=0; i< N ; i++)
  printf("%s\t\t%s\n",Tname[i], name[i]);

}    /* End of main() */
Read more Similar C Programs

Data Structures

 C Sorting
You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!