This is basically the circle of fifths:
This diagram read clockwise is the circle of fifths; read counterclockwise, it is the circle of fourths.
G is a fifth above C, i.e. it is the dominant of the C major scale. F is a fourth above C, i.e. it is the subdominant of the C major scale.
You can see that C is a fifth above F, so it is the dominant of the F major scale.
You can find more info about the circle of fifths here.