Melodies of songs are constructed from notes within a given scale. Occasionally "outside" notes are used, but generally most notes in a melody will come from within the scale; e.g., a melody in the key of C major will use the notes from the scale of C.
C D E F G A B C
A melody in the key of G major will use the notes from the G scale:
G A B C D E F# G
where F sharp will occur rather than F natural.* Instead of placing a sharp sign in front of every F note, a key signature is used. Every major scale has a different key signature which shows the number of sharps or flats contained within the scale. The key signature is written at the beginning of each stave of music (directly after the treble clef). For the key of G major, a sharp sign is written on the F line, indicating that all F notes are to be played as F sharp:
Therefore, the key signature of G major contains one sharp, F sharp.
The C major scale contains no sharps or flats, hence the key signature will also contain no sharps or flats, and is represented thus:
* A natural note is a note that is neither sharpened nor flattened. Natural signs ( @ ) are used in music to cancel the effect of a sharp or a flat.