Code for the Imperative Programming part