Why is electric flux through a cube the same as electric flux through a spherical shell? If a point charge $q$ is placed inside a cube (at the center), the electric flux comes out to be $q/\varepsilon_0$, which is same as that if the charge $q$ was placed at the center of a spherical shell.
The area vector for each infinitesimal area of the shell is parallel to the electric field vector, arising from the point charge, which makes the cosine of the dot product unity, which is understandable. But for the cube, the electric field vector is parallel to the area vector (of one face) at one point only, i.e., as we move away from centre of the face, the angle between area vector and electric field vector changes, i.e., they are no more parallel, still the flux remains the same?
To be precise, I guess, I am having some doubt about the angles between the electric field vector and the area vector for the cube.
 A: The net flux is the same, but this doesn’t mean the flux is uniform.  
Think of a similar situation where you place a lightbulb inside a closed lampshade.  The net flux is the total amount of light passing through the lampshade.  This depends only on the amount of light produced by the lightbulb, not by the position of the lightbulb.  
In other words, if you can take a 60W lightbulb and move it anywhere inside your (closed) lampshade, and this will not change the total amount of light that goes through the lampshade.  Of course unless you place the light bulb exactly at the center of a spherical lampshade, the amount of light will be NOT be uniform on every surface of your lampshade, but that not the net flux, which is the sum total of light of all the light on the entire lampshade.
Note I didn’t discuss the shape of the lampshade or its size.  The net flux is determined by the strength of the source, not by the surface through which the light passes.
A: As has already been pointed out the net flux across any closed surface is the same and only depends on the charge enclosed.
That does not necessarily mean the the flux over a given surface area will be the same as you have found out comparing the cube to the sphere. It decreases as you move away from the center of a face of the cube whereas it is constant over the entire surface of the sphere if the charge is in the center. 
But the total flux is obtained by summing up (integrating) the flux over the entire surface. Consider that for a cube and sphere of the same volume, the surface area of the cube is greater than the surface area of the sphere. Integrating the flux over the two surfaces should yield the same value.
Hope this helps 
A: If you doubt it, show:
$$ F = 6\cdot 4\int_{x=0}^R\int_{y=0}^R\frac{\frac{R}{\sqrt{R^2+x^2+y^2}}}{x^2+y^2+R^2}dxdy = 4\pi$$
where the LHS is the flux through a cube with side $2R$ expressed as 6 times the integral over 1 face, and 1 face is 4 times the integral over one quarter-panel, and a quarter-panel extends from $0$ to $R$. The integrand is $\cos{\theta}/r^2$. The RHS is the flux of $\hat r/r^2$ through a sphere of any radius $R$. 
$$ F = 24 \int_{x=0}^R\int_{y=0}^R\frac R{(x^2+y^2+R^2)^{\frac 3 2}}dxdy$$
$$ F = 24\int_{x=0}^R\big[\frac{Ry}{(x^2+R^2)\sqrt{x^2+y^2+R^2}}\big]^R_{y=0}dx$$
$$ F = 24\int_{x=0}^R\frac{R^2}{(x^2+R^2)\sqrt{x^2+2R^2}}dx$$
$$ F = 24\big[
\tan^{-1}(\frac x {\sqrt{2R^2+x^2}})
\big]_{x=0}^R$$
$$ F = 24\tan^{-1}(R/\sqrt{3R^2})=24\tan^{-1}(\frac 1 {\sqrt 3}) = 24 \times \frac{\pi} 6 = 4\pi$$
Q.E.D.
A: Consider the flux through a tiny segment of a sphere. Since the electric field is parallel to the normal of the surface at all points, the flux is simply the electric field at that distance multiplied by the area of the element.

Now imagine tilting the top of the cone by an angle $\theta$ so that the corners still lie on the conical section, as seen below:

The area increases by a factor $\frac{1}{\cos\theta}$, however the electric field vector in the normal direction $E_n$ is decreased by a factor of $\cos\theta$. Therefore the flux through this surface is unchanged since flux is the product of the normal electric field component and the area.
Now  imagine splitting the cube up into lots of these conical sections. Clearly the tilting of the top surfaces of these sections due to the fact it being a cube rather than a sphere does not affect the flux flowing through each area element. Therefore the total flux flowing through the cube is the same as a sphere.

Note that this was a simplified adaptation from a chapter of The Feynman Lectures on Physics which explains why the images do not quite match my explanations since I was just talking about the top surface of the conical section being tilted. Feynman explains the effect of the flux through a closed surface in a more complete way.
A: 
Why does electric flux through a cube is same as that of electric flux through a spherical shell?

This is not only true for a cube or a sphere. The flux passing through any closed surface enclosing a net charge $q$ is $q/\varepsilon_0$. This is based on Gauss's law for electric charges. 
When the field lines emerge from a point charge uniformly in all directions, the flux passing through any closed surface depends on the relative number of field lines which go into or out of the surface. For a charge inside the surface, the field lines either go out or come in depending upon the fact whether the charge is positive or negative respectively. For an external charge the net number of field lines which go in or come out of the surface is zero and hence it's flux contribution is zero.
So it doesn't matter whether it's a sphere or a cube (or even anything else), as long as a net charge of $q$ lies inside it, the total flux passing through the surface is $q/\varepsilon_0$. Also even if only one charge is present, it's not necessary for the charge to be at the geometric centre of the Gaussian surface.
A: From Gauss's law
$$\int\vec{E}.d\vec{s}=\frac{q_{in}}{\epsilon_{0}}$$
So the flux through both of the surfaces would be same as the charge inside both of the surfaces is same.
If we approach the problem through integral, you mislooked the angle between area vector and electric field in the case of cube.
A: A good way to visualize the problem is to imagine first that the charge is enclosed by a sphere.  Draw a small area on the surface of the sphere, ane draw lines from the charge through the small area. Those lines are the flux through the area. Now imagine a larger sphere concentric with the first one.  The continued lines trace out an area of the same shape on the second sphere, and the same lines pass through that second area.  Now deform the second sphere into a cube, but leave the lines alone.  Imagine the area the lines will trace out on the cube.  Even though the new area is tilted relative to the corresponding area on the sphere,  and the new area is distorted, all the same lines pass through it.  In other words, the flux through the (tilted & distorted) area is the same as it was through the corresponding area on the sphere.  The mathematical operation is an expression of this fact.
