Solution for ex 1-6