Coded in C++