summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/pluraltx.c
blob: b0a616b33e49d1cf2491a1bedfd3b8fa4a9f3cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
**  PLURALTX.C - How to print proper plurals
**
**  public domain - original algorithm by Bob Stout
*/

#include <stdio.h>

#define plural_text(n) &"s"[(1 == (n))]
#define plural_text2(n) &"es"[(1 == (n)) << 1]

void main(void)
{
      int i;

      for (i = 0; i < 10; ++i)
            printf("%d thing%s in %d box%s\n", i, plural_text(i),
                  i, plural_text2(i));
}