Charge supplied by the battery,
q=CV
Energy supplied by the battery,
E=qV=CV2
Energy stored in the capacitor,
U=12CV2
∴ Energy dissipated across R in the form of heat
=E−U
=12CV2=U