completed coding for ex 20. Get different output