The C Programming Language, 2nd Edition, by Kernighan and Ritchie
Exercise {{{1}}} on page {{{2}}}
{{{3}}}
{{{4}}}
Warning: the answers on these pages are crowdsourced, open to anybody to provide/edit after free sign-up, have not all been vetted, might not be correct, let alone optimal, and should not be assumed to be.