C প্রোগ্রামিংয়ের Statements সম্পর্কে আলোচনা

Submitted by tushar pramanick on Mon, 02/25/2013 - 10:16

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.

 

Comments

Related Items

The goto Statement

The goto Statement

The continue Statement

The continue Statement

The break Statement

The break Statement

You can add a break statement at the end of the statement list following every case label, if you want to exit the switch construct after the statements within a selected case are executed.

The switch Statement

The switch Statement

Nested if Statements

Nested if Statements

As you saw in the previous sections, one if statement enables a program to make one decision. In many cases, a program has to make a series of decisions. To enable it to do so, you can use nested if statements.