translated example 2 into C