home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / snip1292.zip / PLURALTX.C < prev    next >
C/C++ Source or Header  |  1991-09-12  |  404b  |  20 lines

  1. /*
  2. **  PLURALTX.C - How to print proper plurals
  3. **
  4. **  public domain - original algorithm by Bob Stout
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. #define plural_text(n) &"s"[(1 == (n))]
  10. #define plural_text2(n) &"es"[(1 == (n)) << 1]
  11.  
  12. void main(void)
  13. {
  14.       int i;
  15.  
  16.       for (i = 0; i < 10; ++i)
  17.             printf("%d thing%s in %d box%s\n", i, plural_text(i),
  18.                   i, plural_text2(i));
  19. }
  20.