Take each note in the original melody and determine its scale degree. For example, to transpose c major to d major, you would substitute the original c major to the d major that corresponds to the same scale degree.
Many scales are diatonic including Major, Minor (the Harmonic minor is an exception) and modal scales. Examples of non-diatonic scale are pentatonic, octatonic and whole-tone scales.