Sunday, December 27, 2009

FUNCTION main

Function is a base of C++ program arrangement. So, it will always be exist in C++ program. At least, you'll have one function in your C++ program. This essential function is called as "function main."
#include

void main()
{
        cout << "Welcome to C++";
}
In the program above, main is the name of the function. Meanwhile, void is a statement to state that the function has no return value.

Everything shown from "{" to "}" is called as block. "{" is to show the beginning of the program, and "}" is to show the end of the program.


The character "(" and ")" are used to fill the argument of function main. In the example above, the () is empty. It means that the function main has no argument.

#include

#include

void main()
{
         cout << "Welcome to C++";
}
#include is used to command the compiler to use the file "iostream.h"

iostream.h is a header file which is already installed inside the compiler. iostream.h is needed inside the program above, because the block ( marked by "{" and "}" ) uses cout.  

cout itself is used to out: Welcome to C++ on the screen as the standard output of C++ compiler.

Saturday, December 26, 2009

EXAMPLE OF C++ PROGRAM

Below is one example of C++ program.

#include

void main()
{
         cout << "Welcome to C++";
}

The program is so simple, but it's ready to run in a C++ editor/compiler, such as Borland C++, Visual C++, Microsoft C/C++, Turbo C++, etc.

The program above will appear: Welcome to C++ as the output on the computer screen.