A capacitor having initial charge q0 = CE /2 is connected to a cell of emf E through a resistor R as shown . Find the total heat generated in the circuit after the switch S is closed.