To harmonize a melody, you simply play a chord which contains a note from that melody on the first beat of each bar. In time, you could also add another chord on the third beat of the bar. There is always more than one chord which could be used, but some sound better than others. The more songs you learn and analyze, the easier it becomes to find the best chords to play. In the scale and chords above, you can see that the notes C and G appear in more than one chord. This means that if you were harmonizing a melody in the key of C, you could try both chords wherever one of these notes appears on the first beat of a bar. This melody in C major is harmonized with chords I, IV and V .
Although most melodies can be harmonized using only chords I, IV and V, it is also common to use one or more of the remaining chords (II, III, VI and VII ) to create a different feeling. These other chords are called secondary chords. As with primary chords, the secondary chord chosen for the harmony in any given bar should contain the melody note which occurs on the first or third beat of that bar (wherever the chord changes). Here is the melody from the previous example harmonized with both primary and secondary chords,