Detailed description
One can also perform the above program by using functions in it.I would suggest to do it.
Also proper documentation is needed for the code.
Context
According to me using functions while writing a code makes it more readable and the code can easily be understood as it is split into pieces of small blocks.
Possible implementation
Usage of functions in the code.
Additional information
none