That depends. A random number guessing game is just a few lines of code and doesn't require intricate knowledge of a programming language.
GameCreator has a valid point. My suggestion is to start small. Take GameCreator's advice and create a random number game. After you finish that, take a stab at another little game. You need to build up your skills (which is often overlooked by new programmers).
This is the hard, but very real truth. You can't create a game in a language if you do not know the language. Learn your basics and learn them well.
But still on basics
If you are still on basics, you can't make a game.
Learn the language first.
EDIT: I figured I would answer your original question as well. If you look online quite a few companies have released the source code to their games. Id Software's Doom 3 comes to mind. You can find the source code here. With that being said, be prepared to have it handed to you. The level of coding that goes into games is extremely high. With that being said, however, studying other peoples code is an important part of learning to program.