I tried to create duplicate array and count a non zero numbers frequency, but frequency value remains one and does not change . Please debug
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t,ns,fimax=0,smax=0,hrec=0,brec=0,freq=0;
cin>>t;
while(t--){
cin>>ns;
int a[ns];int d[ns];
for(int i=0;i<ns;i++){//to create array and duplicate arrray
cin>>a[i];
d[i]=a[i];
}
for(int i=0;i<ns;i++){
if (d[i]==0){continue;}
for(int j=0;j<ns;j++){//to count frequency and change value in duplicate array
if(d[i]==d[j]){
freq=freq+1;
d[j]=0;
cout<<"this is value of freq"<<freq<<endl;
}
}
cout<<freq<<" this is value of freq of arry element "<<a[i]<<" of index "<<i<<endl;
freq=0;
}
}
}```