Answer:
Following is the program given in C++ language.
All the necessary comments are added into the program to make the concept clear.
I hope it will help you!
Step-by-step explanation:
6.5m questions
8.7m answers