got working ex 2-1c
got working function for ex 2-1 d