Power - failed test cases

Its failing some test cases.

#include
using namespace std;

int cal(int x, int p)
{
if(x == 0){
return 0;
}

int ans = 1;
int pow = x;
while(p>0)
{
	if(p&1 == 1)
	{
		ans = ans*pow;
	}

	pow = pow*x;
	p = p>>1;
}

return ans;

}
int main() {
int n,p;
cin>>n;
cin>>p;

cout<<cal(n,p);

return 0;

}

@abhishekchoudhary
hello abhishek ,
a)change datatype to long long
b) pow=pow*pow

It worked.
Thanks!!!