The first law of thermodynamics states that heat is a form of energy and thermodynamics processes are therefore subject to the principles of conservation of energy. The principle of conservation of energy on the other hand states that energy can neither be created nor destroyed, it can only be changed from one form to another.
The mathematical equation for the first law of thermodynamic states that
E = Q - W,
Where E = change in internal energy
Q = Heat added to the system and
W = Work done by the system.
This equation shows that, energy is conserved in the system, that is, the change internal energy of a system is a function of the heat added to the system minus the work done by the system. Thus, all the energy supply to the system has been accounted for and nothing is lost; this is in agreement with the principle of conservation of energy.