ex17.c modified