Schneider Electric Interview Question

I had to write the programme code in C++