Why it is showong the segmentation falult.this is the codeof the target sum (of the all subset which have the subset equal to the given sum)

one important condition which is left is
if(i>=n)return ;
now array is completed

even after that it will not give correct ans because

solve(a,b,k,i+1,j+1);
solve(a,b,k,i+1,j);
cout<<“No”<<endl;
return;

this (cout<<“No”<<endl;) is wrong because it will always excecuted
you can try that also

for that you have to make return type of function as bool if you have print the solution then return true else false
and in main check what is returned according to that print yes or no

modified code https://ide.codingblocks.com/s/228222