Unique numbers 2

here is the code its giving correct output in my compiler.
but its showing wrong answer in hackerblocks.
#include
using namespace std;
int main() {
int n,i;
cin>>n;
int res=0,arr[n];
for( i=0;i<n;i++)
{cin>>arr[i];
res=res^arr[i];}
i=0;
n=res;
while(n)
{
if(n & 1)
break;
n=n>>1;
i++;
}
int mask=1<<i,num1=0;
for(i=0;i<n;i++)
if(arr[i] & mask)
num1=num1 ^ arr[i];
res=res ^ num1;
cout<<res<<" "<<num1;

return 0;

}

Please for the next time, try to share your code by using the online IDE.

Use both {} open & closed brackets with care and maintain to do indentation style in programming. It is working particularly for the given problem that means it is not a generalised solution.

Your algorithm is correct almost but you need to understand the loops & their workflow.
I suggest you to dry run the code yourself and you will be able to see mistakes and you will get a good knowledge of the workflow of the program.

If you have any other doubts, please feel free to ask.

how to share code using online ide…??

Thanks rohit kumar for your help.
If you still have queries, Just follow the steps given below:-

  1. Copy your code from your local computer and open https://ide.codingblocks.com/ on your web browser.
  2. Click on save button & you will see an ID after the above url.
  3. Copy that link & share it with us here.

It is as simple as that.

This is the link for the question:----- Question. This is an easy question and depends upon the understanding.