Coal is mainly carbon. Petrol and diesal are hydrocarbons
hydrocarbons >>>>>>>>>>compounds of hydrogen
When fuels burn they react with oxygen from the air
fossil fuels such as petrol,diesel fuel, natural gas and fuel oil consist mainly of compounds called hydrocarbons.
A hydrocarbon contains only hydrogen atoms and carbon atoms.
so when it is burned in the air, carbon dioxide and water are produced.