How to downgrade GCC and G++ in Ubuntu?

Downgrading GCC and G++ compilers in Ubuntu is mandatory to build some packages (like IRSTLM, Giza++, Moses, etc.). In this tutorial, I will present an easy way to install gcc-4.4, gcc-4.6, gcc-4.9, g++-4.4, g++-4.6, and, g++-4.9. First of all, you need to update the sources repository using a text editor…