Only 2 cases and sample case coming out right

#include
#include<math.h>
using namespace std;
int main() {
int a,b,c;
cin>>a;
if(a==1||a==2)
cout<<"-1";

else if(a%2==0)
{
	b=(a*a)/4 -1;
	c=pow(a/2,2)+1;
}
else if(a%2!=0)
{
	b=((a*a) -1)/2;
	c=pow((a+1)/2,2)+pow((a-1)/2,2);
}
cout<<b<<" "<<c;
return 0;

}

Hello @parastandon4,

There are two issues with your code:

  1. The range of variables is smaller than required
    N can be 10^9,
    You need a datatype of larger range than int for storing c.
    Modification:
    long a,b,c;

  2. Your code will print junk values of c and b for the cases when a is 1 or 2.
    Solution:
    Place the output statements inside the if else block.

Hope, this would help.
Give a like, if you are satisfied.

still 2 cases are wrong even after ythe modification

Hello @parastandon4,

You might be doing something wrong while modifying your code as per my suggestion.

I have modified it:

Hope, this would help.
Give a like, if you are satisfied.

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.

@parastandon4 i see you have re-opened your doubt, can you please specify what problem you are facing and share the link for the code as well

Figured it Out myself ,sorry for the trouble

@parastandon4 please mark the doubt as resolved.

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.