Assume that the pill consists of a cylinder with a semicircular cap at each end.
The two caps will together have the volume of a sphere=4πr^3/3 where r is the radius=3mm or 0.3cm.
The cylindrical middle section has a volume=πr^2h, where h is the length of this section=18-6=12mm or 1.2cm, because we need to subtract twice the radius (i.e., the diameter of the sphere).
volume of sphere+volume of cylinder=4πr^3/3+πr^2h=πr^2(4r/3+h).
Put r=3 and h=12: 9π(4+12)=144π cubic millimetres. 1 cubic centimetre=1cc=1ml. 1cm=10mm, so 1cc=1000 cubic millimetres, and 1 cubic millimetre=0.001cc=0.001ml.
This volume is 0.144π ml=0.4524 ml or cc. Note that volume is measured in cc or ml, not cm.