Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 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