14. Examples:-
Compare each characters starting from the 1st row.
Compare using strcmp function(Don’t use built in)
In strcmp function,
• If 1st character of string 1 == 1st character of string 2,
-> Move to the next character.
• If 1st character of string 1 > 1st character of string 2,
-> Swap the strings.
• If 1st character of string 1 < 1st character of string 2,
-> Don’t swap.
Assignment 6
15. Examples:-
Comparing ‘A’ from Arunachal and ‘B’ from Bengaluru
‘A’ < ‘B’, so don’t swap.
Assignment 6
1000
2000
3000
500
504
508
A r u n a c h a l 0
B e n g a l u r u 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
A g r a 0
16. Examples:-
Comparing ‘B’ from Bengaluru and ‘A’ from Agra.
‘B’ > ‘A’, so swap the strings.
Assignment 6
1000
2000
3000
500
504
508
A r u n a c h a l 0
B e n g a l u r u 0
A g r a 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
17. Examples:-
Comparing ‘B’ from Bengaluru and ‘A’ from Agra.
‘B’ > ‘A’, so swap the strings.
Assignment 6
1000
3000
2000
500
504
508
A r u n a c h a l 0
A g r a 0
B e n g a l u r u 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
18. Examples:-
Comparing ‘B’ from Bengaluru and ‘A’ from Agra.
‘B’ > ‘A’, so swap the strings.
Assignment 6
1000
3000
2000
500
504
508
A r u n a c h a l 0
A g r a 0
B e n g a l u r u 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
19. Examples:-
Comparing ‘A’ from Arunachal and ‘A’ from Agra.
‘A’ = ‘A’, so compare the next character.
Assignment 6
1000
3000
2000
500
504
508
A r u n a c h a l 0
A g r a 0
B e n g a l u r u 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20. Examples:-
Comparing ‘r’ from Arunachal and ‘g’ from Agra.
‘r’ > ‘g’, so swap the strings.
Assignment 6
1000
3000
2000
500
504
508
A r u n a c h a l 0
A g r a 0
B e n g a l u r u 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
21. Examples:-
Comparing ‘r’ from Arunachal and ‘g’ from Agra.
‘r’ > ‘g’, so swap the strings.
Assignment 6
3000
1000
2000
500
504
508
A g r a 0
A r u n a c h a l 0
B e n g a l u r u 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
22. Examples:-
Comparing ‘A’ from Arunachal and ‘B’ from Bengaluru.
‘A’ < ‘B’, so don’t swap.
Assignment 6
3000
1000
2000
500
504
508
A g r a 0
A r u n a c h a l 0
B e n g a l u r u 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
23. Examples:-
This is the sorted order of names.
Assignment 6
3000
1000
2000
500
504
508
A g r a 0
A r u n a c h a l 0
B e n g a l u r u 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19