C++ Tutorial.

Here is a simple tutorial for the classic application, “Hello world”, but you can change the text to whatever you want.

Step 1: Make sure you have a C++ compiler, i reccomend using Bloodshed Dev C++ as it is the easiest to use and is best for begginers.
Download Dev C++

The first thing you need to do is to understand the concepts of the program. The first part is the declarations.

#include <iostream>

This allows your program to accept basic input and output.

The next part is just the rest of the program:

Copy and paste the whole thing into a blank project in Dev C++ and call it hello.cpp.

********************************************************************************

#include <iostream>//allow basic input and output

using namespace std;

int main (int argc, char *argv[])//allow character input
{
char quit;

quit = ”;
while (quit != ‘q’)//if the user presses q then it exits
{
cout << “Hello World.” << endl;
cout << “Welcome to my first app” << endl;
cout << “Windows 32 based” << endl;
cout << “Press q to quit ” << endl;
cin >> quit;
}

return 0;
}

********************************************************************************

The first part sets quit (q) as the quit variable, so when the program needs to accept input for the quit part it just calls upon this first bit.

The next bit (cout) prints text to the screen, simple really, you can add as many lines like this as you want, although they will print all at once without a wait section.

The final bit (cin) accepts c input and waits for quit which is the q button, however the person has been told before which button is quit so when q is pressed the quit variable is activated and the application exits.

Just press compile and run and watch it go, more advanced tutorials can be found at C++.com

Leave a Reply