Give reason haloalkanes react with KCN to form alkyl cyanide as the main product while with AgCN alkyl isocyanide is the main product.
KCN is primarily an ionic compound that produces cyanide ions in solution. Although both the carbon and nitrogen atoms of CN have the ability to contribute electron pairs, the assault is focused on the carbon atom rather than the nitrogen atom because the C-C bond is more stable than the C-N link. However, in nature, AgCN is mostly covalent, and nitrogen is free to contribute electron pairs, resulting in isocyanide as the primary product.