Statements
In the C language, a statement is a complete instruction, ending with a semicolon. In many cases, you can turn an expression into a statement by simply adding a semicolon at the end of the expression.
For instance, the following
i = 1;
is a statement. You may have already figured out that the statement consists of an expression of i = 1 and a semicolon (;).
Here are some other examples of statements:
i = (2 + 3) * 10;
i = 2 + 3 * 10;
j = 6 % 4;
k = i + j;
Also, in the first lesson of this book you learned statements such as
return 0;
exit(0);
printf ("Howdy, neighbor! This is my first C program.\n");
Statement Blocks
A group of statements can form a statement block that starts with an opening brace ({) and ends with a closing brace (}). A statement block is treated as a single statement by the C compiler.
For instance, the following
for(. . .) {
s3 = s1 + s2;
mul = s3 * c;
remainder = sum % c;
}
is a statement block that starts with { and ends with }. Here for is a keyword in C that determines the statement block. The for keyword is discussed in Hour 7, "Doing the Same Thing Over and Over."
A statement block provides a way to group one or more statements together as a single statement. Many C keywords can only control one statement. If you want to put more than one statement under the control of a C keyword, you can add those statements into a statement block so that the block is considered one statement by the C keyword.