Effect of short- and long-range forces on the properties of fluids. III. Dipolar and quadrupolar fluids