solved ex2.2 & ex2.3