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

Manipulating Bits

Manipulating Bits

In previous hours, you learned that computer data and files are made of bits (or bytes). There is even an operator in C_the sizeof operator_that can be used to measure the number of bytes for data types.

Everything Is Logical

Everything Is Logical

Now, it's time for you to learn about a new set of operators: logical operators.

There are three logical operators in the C language:
&&     The logical AND operator
||     The logical OR operator

Question and Answer

    Q Why do we need the sizeof operator?

Exercises : Answer the following Question

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

Playing with an Infinite Loop

Playing with an Infinite Loop

If you have a for statement like this,

for ( ; ; ){
  /* statement block */
}