In this paper, using simulation code CRPropa3. 0, the propagation of 104 primary COSMIC RAYs of proton and iron with energy range of 1018 to 1021 eV was simulated. The spectra of the secondary photons and electron-positrons generated in the interactions of ultra-high energy COSMIC RAYs (UHECRs) with COSMIC background photons were investigated. The photon and electron spectra considered here are generated in photopion production, beta decay, and pair production. The minimum energy of primaries and the spectral index of source injection is changed separately and the effect of these changes on the spectra is investigated. Also, the total primary energy percent which transfers to secondaries, is calculated. It is found that for both primaries, lowering the minimum energy of the primaries leads to the decrease of the flux of secondaries. This also results in the decrease of the total energy percent carried by beta and photopion products and the increase of the energy percent of pair production. Finally, in is shown that by increasing the spectral index, the flux and the energy percent of all secondaries decreases for proton and iron primaries.