-
Notifications
You must be signed in to change notification settings - Fork 0
/
MOH9.C
42 lines (42 loc) · 817 Bytes
/
MOH9.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<stdio.h>
#include<string.h>
void main()
{
char names[100][20],temp[50],addr[100][40];
int ch=0,c,j=0,i=0,num=0;
clrscr();
printf("\n\tstart entering the names ");
while(1)
{
printf("\n\tenter the name: ");
gets(names[i]);
printf("\tenter the address: ");
gets(addr[i]);
printf("\t\t\t\t\tpress 1 to finish ");
i++;
fflush(stdin);
ch=getch();
if(ch=='1')
break;
}
for(c=0;c<i;c++)
for(j=c+1;j<i;j++)
{
num=strcmpi((names+c),(names+j));
if(num>0)
{
strcpy(temp,(names+c));
strcpy((names+c),(names+j));
strcpy((names+j),temp);
strcpy(temp,(addr+c));
strcpy((addr+c),(addr+j));
strcpy((addr+j),temp);
}
}
printf("\nThe names in sorted order are ");
for(c=0;c<i;c++)
{
printf("\n\t%s \t%s",*(names+c),*(addr+c));
}
getch();
}