Basic C++ Tutorial

Going over the very basics of C++

Program: Dev-C++
Language: C++
Difficulty: * (Out of Five Stars)

The Code we will make:

Code:

#include

using namespace std;

int main() {

cout << “Hello World!”;
cin.get();

return 0;
}

Part One: How to Start

So you want to start programming C++ but don’t know were to start? In Part One I will teach you on how to start programming. 
C++ if different than web coding like most of you probably know or tried. In C++ it doesn’t need starting tags. (Example: , , , etc) Also it needs a compiler to make the code into a program. Every Compiler is different, they have their own tools, and coding that they can understand. One thing that is good is all compilers can understand all kinds of code just by entering libraries into your code, which we will go over later.

The Compiler I use: Bloodshed or Dev-C++ 
Both are the same program, but called a different name (I mostly call it Dev-C++)

Part Two: Hello World!

The easiest way, that I have found, to learn how to code is to cut the code down and tell what each part does. That is what I will do in my tutorials.

Code: Hello World!

Code:

#include
using namespace std;

int main() {

cout << “Hello World!”;
cin.get();

return 0;
}

#include = #include is a preprocessor that tells the program to include a code called iostream. Iostream is a library that is used for mostly all C++ coding. 

using namespace std; = This is a statement that tells the compiler to use a group of functions from the std (Standard Library). Using this makes you able to use code like cout, which is used to write text. The semicolon is part of the C++ syntax that tells the compiler to end the statement.

int main() { = This means that there is a function named main and it returns as a integer. (int) The curly brackets tell the code that it is the beginning of a function.

cout << “Hello World!”; = Cout is what is used if you want to output text. After cout comes the two << signs. These are called “insertion operators” which tells the compiler what to output. All text that is going to be output have Quotes around it. After it all comes a semi colon which tells the code it is the end of the statement.

cin.get(); = cin.get(); is the same thing as system(”PAUSE”); They make it so you have to press enter to exit out of the program. (without one of these your program will not start) The only different between the two is that cin.get(); will not enter any text into your program and with system(”PAUSE”); it will put “Press Enter to Continue” so the people that are using your code will know to press enter to exit. (I use cin.get(); most of the time)

return 0; = This tells the compiler that there is no more code after this. Some compilers don’t need this at the end but it makes your code look more professional

} = The last part of the code. it tells that it is the end of the main(); function. (we used a { to tell the beginning of the function so we have to use a } at the end)

Learn More: CLICK HERE

10.05.03

Nice guide but I have a program for you. If you are interested in giving a try to this problem, send me a message. It’s a fun program.

10.05.03

vai ami C and C++ shekhar jonno onek try korchi but parchina.karon amr laptop e windows 7 OS.eitay ei 2ta program run korena.amk jodi bolten kivabe ki korle ami amr laptop e ei 2ta program chalate parbo tahole khub upokrito hotam.amk plz C and C++ download korar link den abong ei 2ta chalate jodi onno kono software use korte hoy tahole seitar nam ebong seita download korar link ta plzzz den…….

10.05.03

Excellent tutorial!

You’re apparently having the same problem I had when I tried to publish a C++ tutorial on Yahoo Voices.

Your include statement was published as follows:
#include

In order to have the ‘include iostream’ statement appear in the published version, you need to place a spaces as follows

#include

and then tell the reader not to include spaces between the brackets and the word iostream.

10.05.03

Sorry. My method for the include iostream statement obviously did not work.

comments powered by Disqus
Loading