Learning to program in C: 7 steps (with pictures)

Table of contents:

Learning to program in C: 7 steps (with pictures)
Learning to program in C: 7 steps (with pictures)
Anonim

Learning to program is certainly not something you learn overnight, and requires a lot of work and dedication (especially with C++). This guide will help you through the process.

Steps

Learn C++ Programming Step 1

Step 1. Learn about the history of C++

The best way to get started with a programming language is to learn its roots. While you won't understand everything you read, some of these pages will introduce you to important terms that will be covered later (such as "Object Oriented Programming").

Learn C++ Programming Step 2

Step 2. Install a C++ compiler (and possibly IDE)

A compiler is required for programming in C++ because the actual source code must be compiled into a file that can be run by your computer. If you're using Windows, a good option is Visual C++ 2010 Express, or if you're using Linux, Geany is a good one. Both come with an IDE (Independent Development Environment), which makes the process of writing the source code much easier. (Note: Many people online will recommend using Bloodshed Dev-C++ IDE and compiler. Don't. It hasn't been updated in 5 years and has pages and pages of known bugs, as listed here: http://sourceforge.net/ p/dev-cpp/bugs/)

Learn how to use the IDE efficiently. Some IDEs out there have their own quirks that can eventually get in the way, so it makes sense to keep a record of and review the various options and settings for your IDE

Learn C++ Programming Step 3

Step 3. Pick a few tutorials to start learning C++

This step, along with the compiler, is one of the most important. There are a few things to take care of during this step. First of all, make sure that the manual is written for complete beginners in programming, as they are the most thorough in their descriptions. Next, make sure that the code in the tutorial follows the C++ 03 standard, or even the new C++ 11 (not yet standardized, so beware of compiler problems), as modern compilers have trouble compiling outdated code, or will simply serve refuse. Some good ones are cprogramming.com on C++ and the tutorial at www.cplusplus.com/doc/tutorial/.

Learn C++ Programming Step 4

Step 4. Try out each new concept

An important part of learning to program is not just reading about the different concepts, but applying them in your own code. Copying and pasting the code into your IDE will only be of limited use. It is much more beneficial to type out each example and try for yourself to work out your own ideas for programs that use the concept learned to maximize the amount of information you can remember.

Learn C++ Programming Step 5

Step 5. Learn from other developers

One of the best things about programming is that no matter what level of programming proficiency you have, there is always source code available that is at that level or a step above it. A good way to learn from the more complicated source code is to read it until you get to a point where you don't understand it, then try to work it out in your head; If you don't understand a specific part of the code, read more about it in your tutorial or reference material until you do.

Learn C++ Programming Step 6

Step 6. Work through the problems using the concepts you have learned

The absolute best way to keep what you learn is not just to overwrite the samples from the source code, but to actually perform some task with it. The website cprogramming.com and Project Euler have good exercises you can try to solve to apply the concepts to real-life situations. If you absolutely cannot create an algorithm for a problem, your last resort is to check online to see how someone solved it to learn from it. What's the point of solving a problem if you don't learn anything from the result?

Learn C++ Programming Step 7

Step 7. Help others who need help

Now that you've learned more about C++, you can start helping other beginners online with their problems, and get them started on the same journey you've taken yourself! Don't get frustrated if the person who asked you for help won't listen to your advice: someone else can learn from the answer you provided, even if the original poster didn't.

Tips

  • Don't get frustrated! Programming can be confusing at times, but that certainly doesn't mean you should just throw away all your progress and quit! If a particular manual explains a topic poorly, try reading another one on the topic; it doesn't have to be you that is the problem!
  • Follow your own pace.
  • If you get errors while compiling, reread the source code and see if you can find the errors. While the errors themselves may seem cryptic, they try to tell you what's wrong, so try to see if they teach you anything about the errors.
  • You can learn C++ through the Google Play store or Appstore, by searching for 'Learn C++'.
  • You can also learn it from a book on C++.
  • If you're getting runtime errors, then the problem isn't a syntax issue, but instead a problem with your algorithm. Write down exactly what your algorithm is supposed to do, and compare it to your source code. Worst case scenario: Show the code to an online community and see if they can help troubleshoot, but ask nicely! The people who help you do that in their spare time, while at the same time they could also earn their money programming software, so be thankful!
  • Always comment on your source code! Even for simple, self-explanatory code, it never hurts to write a brief explanation of the program at the beginning. It's also a good practice to get into if you're going to be programming more elaborate, complex software that you may still understand, but will confuse anyone else reading it.

Warnings

  • C and C++ are very low-level programming languages, which means that there is a possibility that your computer will crash due to faulty code or deliberately malicious programs! NEVER compile programs with '#include ' unless you are absolutely sure of what you are doing, and even if you know what you are doing, try to avoid doing so at all times.
  • Keep your compiler and tutorial up to date! Outdated compilers can cause valid source code to fail to compile or cause weird errors at run time. The same can be said about tutorials.
  • Many antivirus programs will think that whatever you're making is a virus! Make sure to add your program to exceptions and possibly disable your antivirus so that your program is not accidentally removed!

Popular by topic