C major scale
C D E F G A B C
D major scale
-increase each note by 2 semitones:
so C will become D, D will become E, but E will become F# since there is no E#, and so on...
in the end you will get
D E F# G A B C# D
lets say you want to know the Eb major scale
increase 3 semitones from C major:
Eb F G Ab Bb C D Eb
sharps and flats are added to scales in a specific order. you cant have a scale with # on F and G only.
(Add # from top to bottom)
F
C
G
D
A
E
B
(Add b from bottom to top)

this 'series/sequence' of F C G D A E B is very important in memorising scales.
there is an alternative way of using your fingers to count what kind of # and b are present in each scale, but i forget hehe.