k&r; exercise 1.13 - improve solution