• + 0 comments

    my code

    void calculate_the_maximum(int n, int k) {
      //Write your code here.
      int i=0,j=0, result[3], result_store[3], sample[n];
      for (i=1;i<=n;i++) sample[i] = i;
      for (i=0;i<=n;i++)
      {
        for (j=i+1;j<=n;j++)
        {
            if ((sample[i] & sample[j]) < k ) {result [0] = (sample[i] & sample[j]);}
            if ((sample[i] | sample[j]) < k ) {result [1] = (sample[i] | sample[j]);}
            if ((sample[i] ^ sample[j]) < k ) {result [2] = (sample[i] ^ sample[j]);}
            if (result[0]>result_store[0]) { result_store[0] = result[0]; }
            if (result[1]>result_store[1]) { result_store[1] = result[1]; }
            if (result[2]>result_store[2]) { result_store[2] = result[2]; }
        }
      }
      printf("%d\n", result_store[0]);
      printf("%d\n", result_store[1]);
      printf("%d\n", result_store[2]);
    }
    

    On running the code, it gives strange error, while in my local compiler, it works fine.