Let the work done on the object against gravity = W
Work done, W = force × displacement
Work done, W = mg × h
Work done, W = mgh
Since workdone on the object is equal to mgh, an energy equal to mgh units is gained by the object . This is the potential energy (Ep) of the object.
Ep = mgh