K&R is still the best C book IMO, I have a copy right over there and I remember doing that exercise while in school too
With small micros, the level of standards compliance of compilers and libraries vary due to limitations in the compilers or limitations in the target (particularly memory limitations). Most 8-bit compilers are very weak on the library end and often aim at implementing a small subset of the C standard library that is most used in embedded applications. z88dk is different in that regard -- its library is fairly complete but there are still things missing. On the compiler side, compliance refers to what language features are supported. z80 compilers vary from weak standards compliance (mainly early small c implementations), to medium compliance (z88dk's sccz80 is an example) to near full compliance (sdcc is probably by itself in this category).
K&R ansi edition is using C89 which will mostly be supported by sccz80 and sdcc. You can read a little bit about compiler compliance here:
http://www.z88dk.org/wiki/doku.php?id=t ... compliance This is not an exhaustive list but a list of the most notable shortcomings.
Also important is knowing data type sizes:
http://www.z88dk.org/wiki/doku.php?id=t ... data_types
C allows the compiler to decide how any bits are allocated for each type and compilers will choose sizes that the underlying target can efficiently implement. So, for example, on a z80 an int will be 16-bits because it has some 16-bit characteristics which makes ints of that size fairly fast. On an x86 int will be 32- or 64-bit. Programs written for 32-bit ints may not work with the z80's 16-bit ints because the 16-bit int doesn't have as large a range. As long as you are aware of this as programs are written, you will be ok. The new standards have introduced types int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t and uint64_t in stdint.h that define types with their sizes in their names to increase portability of programs.
Within z88dk we have two C compilers now and two C libraries. sdcc is the most standards compliant C compiler and it can be used with the new C library and soon with the classic one as dom is working feverishly on that. sdcc will tend to generate faster code than sccz80 and at one time it also generated larger code but that is not always the case anymore; for code that uses a lot of floats and longs, sccz80 will still tend to be smaller. The new C library has been written from scratch aiming at a subset of C11 compliance but it is still missing disk io. The classic C library has a simpler stdio that is smaller and does support some disk systems.
Anyway I mention these things because if you are following K&R, you should know why things might not work as expected. If you want the maximum compliance combination, that would be sdcc + the new c library as long as you don't need file i/o.
I noted from the test program here that the output formats for %f are not correctly formatted. It looks like the classic c lib may be ignoring the width specifier for %f. I compiled the same for the new c lib and that one too seems to do the %f formatting incorrectly (and the new c lib is supposed to do it all correctly), doing it like %g for the decimal portion. So that is something I will have to look into.