|
|
|
|||
|
Every programming language
provides a structure for decision making. 'C' also provides this structure.
The statement used for decisions in 'C' language is known as the 'if statement'.
The if statement has a simple structure. That is if ( condition ) Statement (or group of statements) We explain it as if condition is
true, then execute the statement or a group of
statements. Here the condition is a statement which explains the condition on
which a decision will be made. We can understand it from the example that Ali
can become the member of the basket ball team if he has a height more than
six feet .In this case, the condition will be if (Alis height is greater than six feet) Ali can be a member of team We have written the condition in English
language. Now let's see how we can implement this in terms of variables,
operators and C statements. In the program, we will write the condition in
parentheses, followed by a statement or group of statements to be executed. Now here is the concept of block
of statements. We use braces { } to make a group (block) of a number of
statements. We put { before first statement and } after the last
statement. Thus if we have to do many things after the if
statement. The structure of if statement becomes as under |
||||
|
|
Previous |
TOC |
Next |
|