Sort String Values – First and Last

The program must accept N string values and sort them. Then the program must print the first and the last string values.

Input :

5

lion tiger elephant monkey leopard

Output :

elephant

tiger

Explanation:
Here N = 5.
After sorting the 5 string values, the string values become elephant leopard lion monkey tiger
Here, the first and the last string values are elephant and tiger.
Hence the output is
elephant
tiger

Here are the various methods and logic.

Python :

#Python code by Agent Hulk
#Python code by Agent Stark
#Python code by Agent Parker
#Python code by Agent Marvel
#Python code by Agent Cherry

C :

#C code by Agent falcon

Java :

#Java code by Agent Steve

Leave a Reply

Your email address will not be published. Required fields are marked *

More posts. You may also be interested in.