I'm working on a problem with an (infinitely) long cylinder with a charge density, and I'm trying to find the electric field. Using the charge density, I found the enclosed charge of a proportional, enclosed Gaussian surface, so
$$Q_enc=\frac{2\pi \ell s^3 k}{3}$$
As such, we know for the Gaussian surface
$$\int{E\cdot \mathrm da}=\frac{Q_{enc}}{e_0}$$
So, you can simply solve this if you know the area, and I know the solution is
$$E = \frac{k s^2 {\hat{\mathbf{s}}}}{3 \epsilon_0}$$
My question is, why do the charges on either end of the cylinder contribute nothing to E? My book tells me this is a result of E being perpendicular to $\mathrm da$, but I don't understand exactly why it that eliminates its contribution. I think it has something to do with the reliance of Gauss' Law on the divergence of E, but I don't entirely understand this in the physical sense. Hopefully the diagram helps, but let me know.