Measurements are presented of the associated production of a W boson and a charm-quark jet (W + c) in pp collisions at a center-of-mass energy of 7 TeV. The analysis is conducted with a data sample corresponding to a total integrated luminosity of 5 inverse femtobarns, collected by the CMS detector at the LHC. W boson candidates are identified by their decay into a charged lepton (muon or electron) and a neutrino. The W + c measurements are performed for charm-quark jets in the kinematic region pt[jet] > 25 GeV, abs(eta) < 2.5, for two different thresholds for the transverse momentum of the lepton from the W-boson decay, and in the pseudorapidity range abs(eta[ell]) < 2.1. Hadronic and inclusive semileptonic decays of charm hadrons are used to measure the following total cross sections: sigma(pp to W + c + X) times B(W to ell nu) = 107.7 +/- 3.3 (stat.) +/- 6.9 (syst.) pb (pt[ell] > 25 GeV) and sigma(pp to W + c + X) times B(W to ell nu) = 84.1 +/- 2.0 (stat.) +/- 4.9 (syst.) pb (pt[ell] > 35 GeV), and the cross section ratios sigma(pp to W+ + c + X)/sigma(pp to W- + c + X) = 0.954 +/- 0.025 (stat.) +/- 0.004 (syst.) (pt[ell] > 25 GeV) and sigma(pp to W+ + c bar + X)/sigma(pp to W- + c + X) = 0.938 +/- 0.019 (stat.) +/- 0.006 (syst.) (pt[ell] > 35 GeV). Cross sections and cross section ratios are also measured differentially with respect to the absolute value of the pseudorapidity of the lepton from the W-boson decay. These are the first measurements from the LHC directly sensitive to the strange quark and antiquark content of the proton. Results are compared with theoretical predictions and are consistent with the predictions based on global fits of parton distribution functions.