sprintf() is a very powerful and flexible function, but most programs only use a small fraction of that power. As a result, code size is bigger than it might need be. The code below shows how to have the same functionality but with smaller code size.
As the program stands, it takes 3400 bytes on my machine. Comment out the sprintf() call and uncomment the rest and it performs the same, but with 2124 bytes. Under some circumstances, the memory savings can be important.