Let say the point is inside the cylinder
then as per Gauss' law we have

here q = charge inside the gaussian surface.
Now if our point is inside the cylinder then we can say that gaussian surface has charge less than total charge.
we will calculate the charge first which is given as


now using the equation of Gauss law we will have


now we will have

Now if we have a situation that the point lies outside the cylinder
we will calculate the charge first which is given as it is now the total charge of the cylinder


now using the equation of Gauss law we will have


now we will have