code for ex1