0% found this document useful (0 votes)
27 views3 pages

Program No.10: / Program To Arrange Data in Alphabetical Order Using Bubble Short

This C program uses bubble sort to arrange student names in alphabetical order. It takes in the number of students, then their names, and stores the names in a 2D array. It then uses a nested for loop with strcmp() to compare adjacent names and swap them if in incorrect order, outputting the sorted list of names at the end.

Uploaded by

Paras
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Program No.10: / Program To Arrange Data in Alphabetical Order Using Bubble Short

This C program uses bubble sort to arrange student names in alphabetical order. It takes in the number of students, then their names, and stores the names in a 2D array. It then uses a nested for loop with strcmp() to compare adjacent names and swap them if in incorrect order, outputting the sorted list of names at the end.

Uploaded by

Paras
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

Program no.

10
/*program to arrange data in alphabetical order

using bubble short*/

#include<conio.h>

#include<stdio.h>

#include<string.h>

void main()

char name[10][10],temp[10];

int i,n,j;

clrscr();

printf("enter the number of student:");

scanf("%d",&n);

printf("enter %d names:\n",n);

for(i=0;i<n;i++)

scanf("%s",name[i]);

for(j=0;j<n;j++)

if(strcmp(name[j],name[j+1])>0)

strcpy(temp,name[j]);

strcpy(name[j],name[j+1]);
strcpy(name[j+1],temp);

printf("storted names are:\n");

for(i=0;i<n;i++)

printf("\n%s",name[i]);

getch();

/*

Output

enter the number of student:4

enter 4 names:

karan

yash

anvi

sham

storted names are:

anvi

karan

sham
yash

*/

You might also like