Consider a system in a state A, having internal energy EN,q amount of heat is supplied to system so that the system attains the state B, having internal energy EB.
Let W is the work done by the system to attain this change, then from first law of thermodynamics.
If ΔE=EB−EA then ΔE=q−W