why is this wrong? Re

#include
using namespace std;
int main(){
int n,a[100];
cin>>n;
for(int i=0;i<n;i++){
int fact=1;
cin>>a[i];
for(int j=1;j<a[i]+1;j++)
fact = fact*j;
a[i]=fact;
}
for(int i=0;i<n;i++)
cout<<a[i]<<endl;
return 0;
}

Factorial values quickly get huge. You should check what value your current code fails at, which isn’t hard to find out with a decent test set. Then think about using more suitable data types (long long perhaps?) and protect against over-limit values. If the answer you are looking for is taken to some modulus then perhaps incorporate that into the function.