1. subset algorithm

Write a recursive function (without using for,while,do while)that fills the given character
array with all possible given-size subsets of characters in
given word, separated by commas. You need to put a
trailing \0 in the character array. You can assume that
the word is at most 10 in length.
void subsets(char word[], int sz, char arr []);
The function then can be used as follows:
char w[] = "abcd";
char r[200];
subsets(w, 2, r );
puts(r );

the output must be
and for
subsets(w, 3, r );
the output must be
abc,abd,acd,bcd
to be printed on the console. Pay attention to the order
of the words—those need to be in the same order as one
produced by the supplied executable!
Here, you can use functions from <string.h>.
can any one help me to find any algorithm or code to due with this question ??
tanq

2. Nope, but if you post your code, we'll try to help you reach a solution yourself.

3. good idea,this is the code ,its not done,i didnt even compile it yet i am working on it but thats it pretty much (by the way i cant use static variable either!!!)
Code:
```#include <stdio.h>

void subsets(char word[], int sz, char arr [])
{
int arrc=0,flag=11,i=0,d=0;
char dep[10];
subsetf2(word,sz,arr,i,d,dep,flag,arrc);

}
subsetf2(char word[],int r,char arr,int i,int d,char dep[],int flag,int arrc)
{
flag=subsetfunc1(word,r,arr,i,d,dep,flag,arrc);
if(flag==strlen(word));
subsetf2(word,r,arr,++i,d,dep,flag,arrc);

}

subsetfunc1(char word[],int r,char arr,int i,int d,char dep[],int flag,int arrc)
{
if(strlen(dep)==r)
{

dep[d]='\0';
flag=d-1;
arrc=arrint(arr,dep,arrc);
return (flag);
}
if(i==flag) subsetfunc1(word,r,arr,++i,d,dep,flag,arrc);
dep[d]=word[i];
subsetfunc1(word,r,arr,++i,++d,dep,flag,arrc);
}
int arrint(char arr[],char dep[],int j,int arrc)
{
if(dep[j]=='\0')
{
arr[arrc]=',';
return(arrc);
}
arr[arrc]=dep[j];
return arrint(arr,dep,++j,++arrc);
}

void main()
{
char w[] = "abcd";
char r[200];
subsets(w, 2, r);
}```

4. That seems a bit too much.

Have you ever watched an odometer work? Do you think you can adapt that idea for your purposes?

5. ya...it works but i dont know how to make the code...my idea is pretty much like odometer but its hard to develop!!

6. First of all, never write that much non-trivial code without compiling. (I did something very similar to this about a year ago and it took me several hours to write and debug)
Without examining your code too closely, it looks like you have the right general idea, although I think your solution is too complicated.
I would reconsider the "odometer" idea since for input (abc, 2), aa, ba, bb, cb, etc are invalid.
Do you have a systematic method of generating these subsets by hand? You might want to explain it here. Putting it in writing might clarify your thought process.