They are both connected to each other. The products of photosynthesis (oxygen and glucose), is used as reactions for cellular respiration. The products of cellular respiration (carbon dioxide, water, and energy) is used as reactions for photosynthesis. So the energy is never created nor lost, the energy is just transferred for the other processes uses.
Hope this helps :)