what is valency? how are elements forming compound?
Elements form compound on the basis of difference in their electronegativites. If the difference is very large, then the ionic compounds are formed in which highly electronegative element donates electron and the electropositive element accepts electron.
If the difference is small, then covalent compounds are formed by sharing of electrons.