This is the question: we need to find the outward flux and verify it using divergence theorem
The main query is that i solved it normally first using $\iint F\cdot n\,dS$ and i got incorrect answer as $3\pi$ and when i solve it using divergence theorem i got the correct answer as $6\pi$.
Can yu please find my mistake?
Here is my solution:
Now one more thing : what is the condition to use green's theorem and stoke's theorem why are they not valid here as i am getting curl 0 so answer will be 0 according to stoke's theorem. The question is how to know when do we use stoke's green's or divergence theorem ?


The divergence theorem deals with a 3d body $B$, its boundary surface $\partial B$, and a vector field $F$ defined in a neighborhood of $B$. It says that $$\int_{\partial B} F\cdot n\>{\rm d}\omega=\int_B{\rm div}(F)\>{\rm d}V\ ,$$ where ${\rm d}\omega$ denotes the scalar surface element on $\partial B$.
In your case $B$ is the upright finite cylinder, bounded by $\partial B=C+D_{-1}+D_2$ with $\>C:=\{x^2+y^2=1, \> -1\leq z\leq2\}$ and two discs at levels $z=-1$ and $z=2$. In your calculation you have just computed the flux $\int_C F\cdot n\>{\rm d}\omega$ through the side wall $C$ of the cylinder. It remains to compute the flux through the bottom disc $D_{-1}$ (where $n=(0,0,-1)$) and the top disc $D_2$ (where $n=(0,0,1)$).