completed problem 4
output of prob6