The production cross section of prompt Λc+ charm baryons was measured with the ALICE detector at the LHC at midrapidity in proton-proton (pp) and proton-lead (p-Pb) collisions at a center-of-mass energy per nucleon pair of sNN=5.02TeV. The Λc+ and Λ¯c- baryons were reconstructed in the hadronic decay channels Λc+→pK-π+ and Λc+→pKS0 and respective charge conjugates. The measured differential cross sections as a function of transverse momentum (pT) and the pT-integrated Λc+ production cross section in pp and in p-Pb collisions are presented. The Λc+ nuclear modification factor (RpPb), calculated from the cross sections in pp and in p-Pb collisions, is presented and compared with the RpPb of D mesons. The Λc+/D0 ratio is also presented and compared with the light-flavor baryon-to-meson ratios p/π and Λ/KS0, and measurements from other LHC experiments. The results are compared to predictions from model calculations and Monte Carlo event generators.