Getting Wrong Answer

The answer for test case of n as 30 and k as 7 is showing answer 0 . Below is my code.

#include <bits/stdc++.h>
using namespace std;

int fact(int n)
{
if(n==0 || n==1)
{
return 1;
}
return n * fact(n-1);
}

int main()
{
int t;
cin>>t;
while (t–)
{
int n,k;
cin>>n>>k;

    int ans = fact(n-1) / (fact(k-1) * fact(n-k));

    cout<<ans<<endl;
}

return 0;

}

@vritant2405 factorials can have really large values that cannot be store in any available datatype in c++

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.