Let us consider a capacitor of capacitance C, with a potential difference V between the plates.
There is a charge +q on one plate and –q on the other.Suppose the capacitor is charged gradually. At any stage ,the charge on the capacitor is q.
Potential of capacitor =q/C.
Small amount of work done in giving an additional charge dq to the capacitor is
dW=q/C *dq
total work done in giving a charge Q to the capacitor is q.
Q=Q
W=1/C Q2/2
Energy stored in the capacitor
U=W=1/2 Q2/C
Put Q=CV
U=1/2 (CV)2/C =1/2 CV2
Put CV=Q
U=1/2 QV
Thus, U=1/2 Q2/C =1/2 CV2=1/2 QV
When Q is in coulomb,V is in Volt ,C is in fared .Energy U is in joule.
Energy stored in a capacitor is in the form of electric field energy in the charged capacitor and it resides in the dielectric medium between the plates.