sort students in alphabetical order code example

Example: sort students in alphabetical order

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

void main()
{
	int i,j,n;
	char student[100][20], temp[20];
	printf("Enter the no. of students:\t");
	scanf("%d", &n);

	
	for(i=0;i<n;i++)
	{
		printf("\nWrite the name of student%d:\n", i+1);
		scanf("%s", student[i]);
	}
	
	for (i=0;i<n;i++)
	{
		
		for (j=i+1;j<n;j++)
		{
			if (strcmp(student[i],student[j])>=0)
			{
			strcpy(temp,student[i]);
			strcpy(student[i],student[j]);
			strcpy(student[j],temp);
		 	}
			
		}
		
		
	}
	printf("\nThe Sorted names are:\n");
	for(i=0;i<n;i++)
	{
		printf("\n%s", student[i]);
	}
	getch();
	
}