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?