Learning how to program

hey,

just one question, whats the best way to learn how to program?
Do you first learn all the basics and later you start programming things, or you program things while you are learning the basics? and if so, how do you program things while you are learning? do you copy source code? do you invent your own stuff?

Do you first learn all the basics and later you start programming things, or you program things while you are learning the basics?

I program basic things while learning the basics.

and if so, how do you program things while you are learning? do you copy source code? do you invent your own stuff?

Copy source code and alter it by inventing my own stuff. Without copying, you would not know where to start; without inventing, you never really learn.

Originally Posted by Bjarne Stroustrup (2000-10-14)

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

You really have to learn the basics before you can do anything. Once you learn about variables (and variable types), loops, branching (if-statements and switch statements), and reading & writing the hard drive, you can start to understand how to do something useful.

Start with the tutorial. You can play around with whatever you are learning.... Most people like to put their name in their first "Hello World" program. When you learn about loops, you might want to make a loop that counts up to one million and displays all the numbers as it counts. When you learn about if-statements, you might want to make a simple guessing-game.

I also suggest you get a book. A good begining C++ book will cover essentially the same information as the tutorials, but with much more detail and explanation. Most C++ books are 300 - 700 pages.

Even better would be to take a class. It will help to keep you focused and moving in the right direction. A lot of us here are learning on our own, but it can be difficult. I've never taken a C or C++ class, but I've taken several classes in other programming languages. After several years of "fooling around" with C++, I'm still not an expert. I think most of the top programmers here on this forum have taken C++ in college. Many are Computer Science majors.

If you are learning on your own it will really help to start on a project (something that interests you) after you learn the basics. It will keep you motivated, and you will need to do research and study sample code in order to figure out how to accomplish your task.