Programming exercise in C