Money Change DP

Here is my code:
#include
using namespace std;
int coin_change(int ar[], int n, int m)
{
int sol[n + 1][m + 1];
for (int i = 0; i <= n; i++) {
sol[i][0] = 1;
}
for (int i = 1; i <= m; i++) {
sol[0][i] = 0;
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
if (ar[i - 1] <= j)
{
sol[i][j] = sol[i - 1][j] + sol[i][j - ar[i - 1]];
}
else
{
sol[i][j] = sol[i - 1][j];
}
}
}

return sol[n][m];

}

int main()
{
int t;
cin>>t;
while(t–)
{
int n,m,i;
cin>>n;
int ar[n];
for(i=0;i<n;i++)
cin>>ar[i];
cin>>m;
cout << coin_change(ar, n, m)<<endl;
}
return 0;
}
what is the error in the above code?

Pls send the link of question

https://online.codingblocks.com/app/player/56968/content/44353/5203

Coding blocks ide is under maintanence. please send your code on another ide.

Hey @Ankit003
Try to use global array
You forgot to use modulo
Also use long long instead of int since result may overflow integer range

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.