What is wrong in this code

#include
using namespace std;
#define MAX 500
int result[MAX];
int size;
void multiply(int i)
{
int carry=0;
for(int x=0;x<size;x++)
{
int prod=(result[x])*i+carry;
result[x]=prod%10;
carry=prod/10;
}
while(carry)
{
result[size]=carry;
carry=carry/10;
size++;
}
}
void factorial(int n)
{
size=1;
result[0]=1;
for(int i=2;i<=n;i++)
{
multiply(i);
}
for(int y=size-1;y>=0;y–)
{
cout<<result[y];
}
}

int main() {
int n;
cin>>n;
factorial(n);
}

Please save your code on ide.codingblocks.com and then share its link. Also mention the question name.

question is broken calculator

Change line 3 to int result[1000000]; and then check.
Smaller sized array will not be able to store the factorial of large numbers like 500!

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.