N Queen Placement Algorithm
===

I was solving the N Queen problem where we need to place N queens on a N X N chess board such that no two queens can attack each other.

    #include <stdio.h>  
    #include <stdlib.h>
    #include<math.h>

    int size=8;
    char arr[8][8];
    int i,j;
    
    void initializeBoard()
    {
      for(i=0;i<size;i++)
      {
        for(j=0;j<size;j++)
        {
            arr[i][j]='.';
        }
      }
    }

    void printArray()
    {
      
      for(i=0;i<size;i++)
      {
        
        for(j=0;j<size;j++)
        {
            printf("%c\t",arr[i][j]);
        }
        
        printf("\n");
      }
      printf("\n\n");
    }

    void placeQueen(int i,int j)
    {
      arr[i][j]='Q';
    }

    int isAvailable(int i,int j)
    {
       int m,n,flag;

       for(m=0;m<i;m++)
       {
          for(n=0;n<size;n++)
          {
            int k=abs(i-m);
            int l=abs(j-n);

            if(arr[m][j]!='Q' && arr[k][l]!='Q')
            {
                flag=1;
            }

            else
            {
                flag=0;
                break;
            }
        }
    }
    return flag;

    }


    int main(void)
    {
    initializeBoard();

    for(i=0;i<size;i++)
    {
        for(j=0;j<size;j++)
        {
            if(isAvailable(i,j)==1)
            {
                // means that particular position is available
                // and so we place the queen there

                placeQueen(i,j);
                break;
            }
        }
    }

    printArray();
    return 0;
}

I think the problem is with the isAvailable() method. However, I am not able to find the bug. Please help me identify it.

**Is the approach that i am taking involves backtracking ?**


 