translated example 7 into C