translated examples 5 and 6 to C