The First law of thermodynamics states that energy is neither created nor destroyed, thus the total energy of the universe is a constant. However, energy can certainly be transferred from one form to another form.
The 1st law of thermodynamics is mathematically stated as follows:
§dQ = §dW
During a thermodynamic cycle, a cyclic process the systems undergoes, the cyclic integral of heat added is equal to integral of work done. the first law equation can also be written in the form,
§(dQ – dW) = 0
Equation dU = dQ – dW is corollary for first law of thermodynamics. It shows that there exists a property internal energy (U) of the system, such that a change in its value is equal to the difference in heat entering and work leaving the system.
Sign convention for heat and work in first law of thermodynamics is represented in picture below.
H = U + pV
For a reversible process, since dW = pdV, the first law of thermodynamics can also be written as
dQ = dU + pdV