How Can I solve the logical error in the flowing code? : <p>No value is being printed inside if condition block.
Where is the logical error?
Thanks.</p>

<pre><code>#include&lt;bits/stdc++.h&gt;
using namespace std;

int fx[]= {-1,-1,-1,0,1,1,1,0};
int fy[]= {-1,0,1,1,1,0,-1,-1};

int ar[20][20];
int n;
int v1, v2;

void fun(int a, int b)
{
    for(int i=0; i&lt;8; i++)
    {
        v1 = a+fx[i];
        v2 = b+fy[i];
        //cout&lt;&lt;v1&lt;&lt;" "&lt;&lt;v2&lt;&lt;endl;
        if(v1&gt;=0 &amp;&amp; v1&lt;n)
        {
            if(v2&gt;=0 &amp;&amp; v2&lt;n)
            {
               // Not executing 
               cout&lt;&lt;"----------"&lt;&lt;endl;
               cout&lt;&lt;v1&lt;&lt;" "&lt;&lt;v2&lt;&lt;endl;
            }
        }

    }
}

int main()
{
    int n;
    cin&gt;&gt; n;
    for(int i=0; i&lt;n; i++)
    {
        for(int j=0; j&lt;n; j++)
            cin&gt;&gt; ar[i][j];
    }
    fun(0,1);
    return 0;
}
</code></pre>

<p>SAMPLE INPUT:<br> 
4<br> 
1 1 1 1<br> 
1 1 1 1<br> 
1 1 1 1<br> 
1 1 1 1<br> 
EXPECTED OUTPUT:<br> 
<p>---------<p>
0 2<br> 
1 2<br> 
1 1<br> 
1 0<br> 
0 0<br> </p>
