ex4

source code for exercise 4