Solutions to programming questions in c++