Any C/C++ code block is delimited by curly braces{}. The bodies of a function,loop,structure, and class, everything must be enclosed between curly braces only with very few exceptions.
They are set of instructions that has main section similar to the C program which is of integer type and is enclosed within
{ }. The execution starts from this point. This part of the program is called as
Function body.
Comments are the statements used in the C++ code to make the user to understand what is happening in the source code given to the compiler without reading the actual code. Comments makes the new user to learn the language easily. Comments are of two types.
Single line comments helps in commenting shortly at the end of a code and can be represented with
//.
[c]cout<<"splessons"<<endl; // cout is console output[/c]
Multi line comments can be used when there is lot of information to be inserted in source code for ease of programming.Multi-line comments can be even in 1 or more lines. They can be represented with
/*...*/ .
[c]
/*Welcome to SPLessons
You are reading C++-programming tutorial
This program is about summing of two numbers*/[/c]
Statements are the instructions of programs and are considered as the building blocks of computer programs. C++ statements can be of many types following certain rules and these can be discussed in further chapters.
In the above program,
cout is derived from iostream which is used to display the output on the console window. 'cout' is then followed by stream-insertion operator
<<.
The output statement enclosed in double quotes
" " which has to be printed. Every C++ statement should end with a semicolon
;.
[c]cout<<"Welcome to SPLESSONS\n"; //C++ statement[/c]
Whitespaces and empty lines are basically ignored by C++. So, they can be inserted.
A new line can be inserted in two ways. By using the well-known escape sequence
\n, or using the
endl manipulator.