The major scales and their appropriate sharps or flats can be arranged in a sequence called the circle of fifths. As you add one sharp to a key signature, you ascend five letter names. As you add one flat to a key signature, you descend five letter names.
|C D E F G||1 sharp = G||C B A G F||1 flat = F|
|G A B C D||2 sharps = D||F E D C Bb||2 flats = Bb|
|D E F G A||3 sharps = A||B A G F Eb||3 flats = Eb|
|A B C D E||4 sharps = E||E D C B Ab||4 flats = Ab|
|E F G A B||5 sharps = B||A G F E Db||5 flats = Db|
|B C D E F#||6 sharps = F#||D C B A Gb||6 flats = Gb|
|F# G A B C#||7 sharps = C#||G F E D Cb||7 flats = Cb|
With the key of C at the top, the fifths lead clockwise to G, then to D, and so on around the circle back to C. Note that at the bottom of the circle, the keys with sharps and flats must overlap. These three sets of keys, each with two key signatures, are called enharmonic keys.