When I strum the strings of a guitar to play a chord, should I hit all the strings or just those I need? Is there a method for working out which strings I need?
Lots of chords played on guitar are not played using all 6 strings. Mainly it's down to voicing, with a sometimes odd sounding note at the bottom, and sometimes it's because a string somewhere in the middle needs muting, as a good note cannot be found to play on it.
Chords can have as few as 3 notes (some argue 2 constitutes a chord), so 3 can be an answer - top 3, middle 3, bottom 3 (power chord territory). Some beginners think that they can only play the strings that they're fretting, but often, open strings work alongside those.
It's going to depend on the song, and other players. A song can be very full and busy, so as many as all 6 strings are used. Or, it can be a sparse accompaniment, when 2, 3 or 4 strings need playing. No hard and fast rules, like a lot of music - more of if it sounds good, it probably is. And the converse, of course...
For more advanced chord playing, there are often too many notes making up a chord, so in those cases, something has to go anyway.
As Tim describes, there are two different skills here: picking accuracy (don't hit strings you don't need) and muting (don't let strings ring out if it's too hard to avoid hitting them). And you should practice both.
Good exercises for picking accuracy are: scales, arpeggios, root-chord-root-chord strumming patterns.
Good exercises for muting: funk -- anything funky, samba, calypso, anything with a polyrhythm or complex rhythmic figure with syncopation.