Yeah as Nathan2222 said, what do you want the source code of? Many things are closed source (i.e. You cannot obtain the source code). Also, it's probably not going to be useful for a long while for you to see the source of many programs. It's really far more effective in the beginning to be learning out of books and from good tutorials, rather than looking at complete and confusing programs written by others, most (or all) of which you will not understand.
As for writing a program, if you want to write C++ programs, they will run on Mac OS X. It already comes with X-Code that you can use for doing this, so all you need to do is grab some beginner C++ books or tutorials and start learning.