Semicolons & Blocks in C++
In C++, the semicolon is a statement terminator. That is, each
individual statement must be ended with a semicolon. It indicates
the end of one logical entity.
For example, following are three different statements:
x = y;
y = y+1;
add(x, y);
A block is a set of logically connected statements that are
surrounded by opening and closing braces. For example:
{
cout << "Hello World"; // prints Hello World
return 0;
}
C++ does not recognize the end of the line as a terminator.
For this reason, it does not matter where you put a statement
in a line. For example:
x = y;
y = y+1;
add(x, y);
is the same as
x = y; y = y+1; add(x, y);
No comments:
Post a Comment