A submarine works in much the same way, with one major exception: a sub can alter its buoyancy by manipulating overall density.Submarines come equipped with tanks that can be filled with various levels of water and air.When a sub floats on the surface, its tanks are filled mostly with air, which makes the sub less dense than the surrounding water.When the crew wants to make the sub sink they open valves to allow just enough water to flood the tanks and make the sub sink to a specific depth.Of course the sub must be able to rise again after filling its tanks with water.To that end submarines carry tanks of compressed air that can be used to displace water from the tanks and increase buoyancy.