280 Programming and Data Structures
I
for (i=l,i<=5-l,i++)
for (j=l,i<=5-ij++)
if(strcmp(name[j-l],name[j])>0)
I
strcpy(temp,name[j-l]);
strcpy(name[j-l],name[j]);
strcpy(name[j],temp);
strcpy(temp,mobilelj-l]);
strcpy(mobile[j-l],mobile[j]);
} strcpy(mobile[j],temp);
printf ("L is t o f Customers in alphabetical Order.");
for (i=0,i<5;i++)
print)f("n% -20st% -10sn",name[i],m obile[i]);
OUTPUT:
Enter Names and Mobile Numbers.
K S MORE 458454
JMCHATE 658963
M M GORE 660585
L K jA IN 547855
j J JOSHI 354258
List of Customers in alphabetical Order.
CHATEJM 658963
GORE M M 660585
JAIN LK 547855
JOSHI JJ 354258
MOKE KS 458454
Explanation The logic used here is the same as the logic used in the program where the city names
are sorted alphabetically.
SU M M ARY
This chapter is focused on strings. In this chapter you have learnt how to declare and initialize string.
It is also very important to identify the end of the string. This is followed by N U LL ( 0) character. The
various formats for display of the strings are demonstrated with an example.
String handling has a strong impact in real life string problems such as conversion of lower to upper
case, reversing, concentration, comparing, searching and replacing of string elements. It is also
discussed how to perform these activities with and without standard library functions. After having
performed programs discussed in this chapter the programmer should not face any problem for
solving string-handling applications.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.158.36