Beginning of C++ codes: All
codes are case sensitive.
Block comment:
Start with /*,
and end by */.
It can be two or more lines.
It provides program reader with information.
It shows who wrote the program.
It also shows the purpose of the program.
The compiler will
not read the block.
Line comment:
Start with //,
end at the end of line.
Tell the compiler to ignore
the rest of that particular line.
It is a place, the programmer can write a remark to remind himself or reader.
#include <iostream> using namespace std; This is a preprocessor section. C++ compiler has some
pre-define codes. If you want to use them, you should include those
header
files.
For example, in order to show something on the screen, we use cout
statement. What is cout
meant? The definition is in the iostream
file.
Therefore, if you want to use cout,
you have to write #include
<iostream> statement before the main program.
void main()
or int main() Main program is a function. That is, once CPU runs through the
whole program, the control of the computer
has to return to operating system.
If you use int
main(), you have to have a return
0; or return
1; statement at the end of main
function.
If you use void
main(), the main function return
nothing to operating system. So, you do not need any return statement.