Energy $U$ is stored in a capacitor is given as $$ U=\\frac{1}{2} \\frac{q^2}{C}=\\frac{1}{2} C V^2 \\quad[\\because q=C V] $$