Code on generating possible ordered pairs upto a number and finding maximum value of binary operations of the pairs : I got a question at hackerrank which states that , a user should input a larger  number (say 5) and a smaller number (say 4) . Then taking each pair from the oerdered list {1,2,3,4,5} , the binary and (&) , binary or(|) and bonary xor(^) are performed . Here , 10 such values of each binary operation are found . The maXIMUM value among the 10 values for a particular operation which is less than 4 ,  is to be printed . My code is as follows :


    #include <stdio.h>

    void main(){
    int n,k,i,a,b;
    printf("ENTER VALUE OF n AND k:");
    scanf("%d%d",&n,&k);
    int Aarr[n*(n-1)/2] , Oarr[n*(n-1)/2], Xarr[n*(n-1)/2];
    for(a=1;a<=n;a++){
      for(b=a+1;b<n;b++){
         for(i=0;i<(n*(n-1)/2);i++){
             Aarr[i]=(a&b);
         }
         for(i=0;i<(n*(n-1)/2);i++){
             Oarr[i]=(a|b);
         }
         for(i=0;i<(n*(n-1)/2);i++){
             Xarr[i]=(a^b);
         }
      }
    }
    int Amax=1,Omax=1,Xmax=1;
    for(i=0;i<(n*(n-1)/2);i++){
       if((Aarr[i]>Amax)&&(Aarr[i]<k)){
          Amax=Aarr[i];
       }
    }
    for(i=0;i<(n*(n-1)/2);i++){
       if((Oarr[i]>Omax)&&(Oarr[i]<k)){
          Omax=Oarr[i];
       }
    }
    for(i=0;i<(n*(n-1)/2);i++){
       if((Xarr[i]>Xmax)&&(Xarr[i]<k)){
          Xmax=Xarr[i];
       }
    }
    printf("\n%d\n%d\n%d",Amax,Omax,Xmax);
    getchar();
 }


**EXPECTED OUTPUT:**
2
2
3


**MY OUTPUT:**
1
1
1

My code is run in the **CODE BLOCKS** IDE . The code just produces the values of Amax,Omax and Xmax as defined . I at first tried to find the all the possible ordered pairs and store them in an array . I think the condition applied to find the maximum value of a particular operation is correct . I've done many debuggings and at last have sought your help . I'm new to C programming . So , my code seem to be too long to you . Any help is appreciated , please . 

Thanks ... 