Why this not getting right?

why this not getting right?

#include #include<math.h> using namespace std; int main() { int n,i,j; cin>>n; if(n%2==0) { i=pow(n/2,2)-1; j=pow(n/2,2)+1; if(i>0 and j>0) { if(i>j) { int temp; temp=i; i=j; j=temp; } cout<<i<<" “<<j<<endl; } else cout<<”-1"; } else { i=(n+1); j=pow((n-1)/2,2)+pow((n+1)/2,2); if(i>0 and j>0) { if(i>j) { int temp; temp=i; i=j; j=temp; } cout<<i<<" “<<j<<endl; } else cout<<”-1"; } return 0; }

hello @dhruvilcodes
pls share ur code using cb ide

i am in collaborate mode and i am not able to share cb ide code please help me

@dhruvilcodes
a)
for n < 3 answer should be -1

b) if n is odd then these are the roots

(n*n-1)/2, (n*n+1)/2

@dhruvilcodes
check ur updated code here->

ok working, Thank you bhaiya.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.