Why is my submission wrong? (problem-XORRY-1)

include <bits/stdc++.h>
#include<math.h>
using namespace std;

int main()
{
int t;
cin>>t;
while(t–)
{
float x,ran;
cin>>x;
ran=x;

    int p=0;
    while(x/2.0>=1)
    {
        p++;
        x=x/2.0;
    }
    
    x=ran;
    
    if(pow(2,p)==x)
    {
        cout<<0<<" "<<x<<endl;
        
    }
    
    else
    {
        cout<<x-pow(2,p)<<" "<<pow(2,p)<<endl;
    }
    
}

}

I noticed a small issue in your code: the subtraction operator in the while loop condition seems to be using an en dash (‘–’) instead of a regular minus sign (‘-’). This might be causing a compilation error.

Here’s the corrected version of your code:

include <bits/stdc++.h>
include <math.h>
using namespace std;

int main()
{
int t;
cin >> t;
while (t–)
{
float x, ran;
cin >> x;
ran = x;

    int p = 0;
    while (x / 2.0 >= 1)
    {
        p++;
        x = x / 2.0;
    }

    x = ran;

    if (pow(2, p) == x)
    {
        cout << 0 << " " << x << endl;
    }
    else
    {
        cout << x - pow(2, p) << " " << pow(2, p) << endl;
    }
}
return 0;

}

Now the code should work as intended. The main change is replacing ‘–’ with ‘-’ in the while loop condition.

I copy pasted the code here. I had written t-- in the original. My code didnt generate compilation error. It even gave correct answers to sample inputs. But upon submission it showed wrong answer

@vedangshendye
bro your logic is not right .
plzz refer the following code.

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
        int t;
        cin>>t;
        while(t--)
        {
            long long int n,hi;
            cin>>n;
            long long int p=1;
            while(p<=n)
            {
                long long int val=p&n;
                if(val==p)
                {
                    hi=p;
                }
                p=p*2;
            }
            long long int ans=n^hi;
            cout<<ans<<" "<<hi<<endl;
        }
}