Answer:
Following is the program given in C++ language.
All the necessary comments are added into the program to make the concept clear.
Step-by-step explanation:
5.2m questions
6.7m answers