About

Translate

Jan 31, 2010

Basic of C++

The following is a program that diaplays "welcome to the world of c++"
//this is the basic example of c++
#include
int main()
{
count<<"Welcome to world oc c++";
return 0;
}
it's output will be
Welcome to the world of c++

The example includes most of the components in a c++ program.
let's take a close look.
//this is the basic example of c++
look here the program starts with double slash indicating a comment and has no implication on the function or purpose of the program. you can add any comment to your program and the second lines starts with # and #include instructs the complier's pre-processor to hold the iostream.h stand and library file standard library of input and output are included in the 'iostream.h' standard file.
int main()
this is the srarting of program, all programs must begin with a 'main' function and the two parenthesis you are seeing is a function declaration the difference between function declaration and the other expression in source code is indicate by parentheses.
{
This is called brace. it indicate the begining of body of the function. the statements mentioned in the main function define the execution process the function.

count<<"welcome to the world of c++";
count generates the visual effects and it is also the output stream and is declared in the 'iostream.h' library file once executed . this statements displays the string "welcome to the world of c++"

return 0;

A return value is usally follows the return statements. in this case the value is 0. The main () function usally has a return value of 0.
The closing brace indicates the end of body of the main function and end of the program.
Reactions:

0 comments:

Post a Comment