C++ programming - Introduction


Nobody becomes a computer programmer without developing programs. Attending class, reading texts, memorizing program syntax and structure is not enough. Hence you must develop several computer programs yourself.

What You Need to Have -
A computer programmer uses a programming language such as C++ to write a set of instructions for the computer to follow - i.e. a program. The computer does not actually respond to C++ code as written. The computer only deals with information in the form of 0's and 1's (bits). To get a program to run on the computer, it has to be in the form of 0's and 1's or machine language. In order to convert C++ source code into executable machine language. we use a special software program called a compiler.

Getting the Compiler -
If you use FreeBSD or Linux you almost definitely already have a C++ compiler. If you need a compiler for Windows, an excellent compiler is availabe from bloodshed.After you download devcpp_4.zip, extract it or unzip it using winzip's wizard option so that you can install it effortlessly.

Writing a Program

I.

It has become a tradition among computer programmers to begin the learning of a computer language by writing a program that prints "Hello world!" to the screen. Let's begin now. Go to Dev-C++ on your computer's Program menu and click Dev-C++.

II.

When the Dev-C++4 user interface appears click on New Project under the File menu.

III.

In the new project dialog box, select Console Application under the Project tab. Make sure the C++ radio button is selected then click OK.

IV.

When the Project name box appears, give your project a name. For our first program enter the name "Hello". Click OK.

V.

Navigate to the directory where you want to save your project and click save. It is a good idea to create a directory for you projects beforehand. You could make a folder on the C: drive called "work" and place folders inside it called "project1", "project2", etc.

VI.

Now your code editor should appear. You can delete the code in it and type the new source code as follows:

#include <iostream>
using namespace std;

int main()
{
cout << "Hello World!";
cin.get();
return 0;
}

VII.
Under the Execute menu click Compile. Save your source code as "project1" and wait for your code to finish compiling. If you typed everything correctly, you will not get any errors and you program is ready for execution.

VIII.

Click execute to see your program run. Click continue to return to the editor.