Gamma rays are a form of electromagnetic radiation related to visible light, infrared radiation and radio waves, except they carry a million times more energy per 'photon'. Cosmic rays are actually electrons, protons and the nuclei of elements such as oxygen and iron which are accelerated in the sun, in supernovae explosions, or by pulsars. They are not forms of electromagnetic radiation, and are a standard 'stock' question used to stump students in introductory astronomy courses all over the world!