That depends on what your instructions are.
I assume that you need to calculate the volume of a sample of material that is shaped as a rectangular prism or as a sphere.
For example, let's say that your material is shaped like a rectangular prism. Its volume will be given by
#V = l * w * h" "#, where
When you calculate the volume, you will end up with whatever unit you have for these three measurements cubed. So, for example, let's say that your prism is
Its volume will be
#V = "4 cm" xx "3 cm" xx "1 cm" = "12 cm"""^3#
If the mass of the sample is given in grams, you can find the density to be
#rho = "grams"/("cm"""^3)#
The units for density can vary quite a lot, depending on what values you have. Common units used for density are
So, if the problem asks you to find the density in kilograms per cubic meter, you can still use centimeters as the unit of length, but you need to make sure that you convert the volume from
Alternatively, you can convert each length from
In this example, you would get
#V = "0.04 m" xx "0.03 m" xx "0.01 m" = 1.2 * 10^(-5)"m"""^3#
If you get something like inches or feet as units of length, and the problem wants you to find the density in grams per cubic centimeter again, you will need to convert those lengths from inches to centimeters.
The bottom line is that the units you need to use for the dimensions of the rectangular prism, if that is the case, will depend on what units the problem wants you to express the density in.