The energy stored on a capacitor can be expressed in terms of the work done by the battery. Voltage represents energy per unit charge, so the work to move a charge element dq from the negative plate to the positive plate is equal toVdq , where V is the voltage on the capacitor. The voltage V is proportional to the amount of charge which is already on the capacitor.
Element of energy stored: dE=dW=Vdq
Hence, relation is E=W