Range of experience is 30 for creeps, 20 for heroes. AFAIK as long as you are in the range you get a slice of the EXP. Doesn't matter if you dealt any damage or not.
Gold is given to the unit that deals the most damage to the dying unit (Unconfirmed, this is what has been said).
Gold/experience per unit:
Demigods: 250 exp, X gold (not sure formula for gold, but its 900 + something for direct kill, half for assist?)
Soldier: 33 exp, 4 gold
Archer: 33 exp, 8 gold
Priest: 50 exp, 33 gold
Angel: 50 exp, 66 gold
Catapultasaurus: 50 exp, 66 gold
Giant: 50 exp, 100 gold
*NOTE: I Have not tested the exp gain from a demigod. That is what is listed in the LUA files. It may be more if the hero is higher level? I assume thats EXP for killing a level 1 hero.
I have a post which links to a spreadsheet with all the details, drawn directly from LUA files.
http://forums.demigodthegame.com/346788