The triangles ABC and EDC are similar which means that the rate between corresponding sides is equal, so that:

We know that
EC=7
AC=21
DC=x
BC=20-x

First, you have to multiply both sides by (20-x) to take the x-term from the denominator's place

Next, distribute the multiplication on the parentheses term:

And pass the x-term to the right side of the equation by applying the opposite operation

Finally multiply both sides of the expression by the reciprocal fraction of 4/3, i.e. the inverse fraction

x=5 → so the length of CD is 5 units.
The correct option is D.