this program "small factorials" is giving wrong answer ,can anyone tell me whats wrong in this?

#include
using namespace std;

int main() {
int i,fac=1,a[100],n;
cin>>n;
for(i=0;i<n;i++) {
cin>>a[i];
}

for(i=0;i<n;i++) {
fac=1;
while(a[i]>1) {
fac=fac*a[i];
a[i]–;
}
cout<<"\n"<<fac;
}
return 0;
}

Please see the :

Constraints

1 ≤ T ≤ 100

1 ≤ N ≤ 100

you have taken int fact. int value is not enough to hold 100!

Your Answer is Coming Wrong Because You Can not store value of factorials in int because you can imagine the number of digits in 100! its very large and int can store in range -2,147,483,647 to 2,147,483,647.

Just You have to add one header file to get correct answer
Here It Is

Hi, you can use long long int for factorials of some no but for some no like 100 (whose factorial has 158 digits) would not be possible from your code to calculate it because c++ does not have any data type to contain such large numbers you can have a look at this link if you are not able to figure out anything - Find the Factorial of a large number - GeeksforGeeks
happy coding, hope I was of some help