In example a., the order of g must be 1, 2, 3, 4, 6 or 12 (those being the divisors of 12. If g has order 1 then g is the identity and so g to any other power is also 1. If g has order 2 then . If g has order 3 then . So if and then the only remaining possibility is that g has order 12. Thus g generates the whole of G.
The other two examples are similar. I'll leave you to think about the generalisation.