the concept of permutations would be useful here. a permutation is basically the **set** of the different possible outcomes of an event. if you dont know set notation or what it is, take a quick look somewhere of what it is)

for example (code tag is used because required when using curly braces):
Code:

flipping the coin n=1 times gives the possible outcomes: {H, T}, 2 outcomes
flipping n=2 times gives the possible outcomes { (HH), (HT), (TT), (TH)}, 4 outcomes
flipping n=3 times gives outcomes: { (HHH), (HHT), (HTH), (HTT), (THH), (THT), (TTH), (TTT)}, 8 outcomes

the number of (uniquely ordered) outcomes for flipping a coin (which has 2 possibilities) n times is 2^n. that would be the theory of it. it isnt necessary for your program, but it may help to understand.

printing these outcomes could be done recursively with a base case of two outcomes, "T" and "H". for example, to print out the outcomes with n=2 we could do:

printOutcomes(2) = (1st outcome 'T'): T + printOutcomes(2-1) = T + T, T + H

= (2nd outcome 'H'): H + printOutcomes(2-1) = H + T, H + H

where "+" denotes concatenation, ie "T + T" is "TT". notice the four outcomes are all of the possible ones, as listed earlier.

i hope im not being too vague that you cant understand, yet i hope im not being too explicit that i did the work for you.