You are way overusing pointers unnecessarily. This also somewhat slows down your code.
Why your code prints the wrong value is that you got confused on the operator precedence. Post-increment comes before dereferencing pointes, so
for (*i = 1; *i <= *a; *i++)
doesn't do what you think it does. The above code actually moves the pointer (i) to the next int in the memory, then dereferences it.
What you should have done is
for (*i = 1; *i <= *a; (*i)++)
Nevertheless, your code is way overcomplicated.
Here's my enhancement of your code:
#include <iostream>
#include <cmath>
static long int factorial(int n)
{
long int product = 1;
while (n > 1)
product *= n--;
return product;
}
int main()
{
int x, y;
std::cout << "Enter the value of x: ";
std::cin >> x;
std::cout << "Enter the value of y: ";
std::cin >> y;
double power = pow(x, y);
long int factSum = factorial(x) + factorial(y);
std::cout << x << "^" << y << " = " << power;
if (power > factSum)
std::cout << " is greater than ";
else if (power < factSum)
std::cout << " is smaller than ";
else
std::cout << " is the same as ";
std::cout << x << "!" << " + " << y << "! = " << factSum << std::endl;
return 0;
}