3g/gps shield on mega 2560

With all due respect I think that you are being a bit ambitious for a beginner.

Get each sketch that you seem to be trying to combine to work separately and once you have achieved that study them to see how they work, the concept of setup() and loop() (there's lots of information on this site). Then basically combine both setup() and both loop(), which is easier said than done as you may pin or library conflicts.

And remember, Tools-> AutoFormat (CTRL+T) is your friend!