The first law of thermodynamics
The first law of thermodynamics is a consequence of the law of conservation of energy, which states that energy can be transformed from one type of energy to another, but it can be neither created nor destroyed - in other words, the energy of the universe is constant.
Figure 1: The first law of thermodynamics states that the energy of the universe is constant.
The change in energy of chemical reactions
When looking at a chemical reaction, this means that if the system (the molecules taking part in the reaction) experiences a change in internal energy, ΔU, then the surroundings (the rest of the universe) will experience a similar change in energy, but with the opposite sign.
The change in internal energy, ΔU, of a system is expressed as
ΔU = q + w
Where q is the amount of heat being transferred and w is the work being performed. The sign of q and w reflects the direction of the flow of heat and work, seen from the systems point of view: If heat flows into the system (which is the case for an endothermic reaction) then q is positive, whereas the opposite is true for an exothermic reaction. If work is being performed on the system (like a piston being pushed to compress the volume) then w is positive, whereas is work is being performed by the system (a gas expanding to move a piston) then w is negative.