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

using namespace std;

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

for(i=0;i<n;i++) {
while(a[i]>1) {
return 0;

Please see the :


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 -
happy coding, hope I was of some help