translated example 9 into C