Submitted programming ex2 (q: 1,2,3)