Through the process of photosynthesis plants use the green coloured pigment named chlorophyll present in their leaves to trap sun light (solar energy) alongside other simple inorganic molecules like atmospheric carbon dioxide and water to produce sugar molecules (usually glucose) which is later stored as starch.
When the diffrence is small like between Oxygen and Carbon the electrons will be shared. When it is large like in Na and Cl the Cl will steal one electron.