This program is coded in C++