Minggu, 04 Oktober 2015

Decision Making In C programming Language

Decision making structures are one the tools which gives C language its power. In these structure the programmer specifically defines one or more conditions what he wants to be evaluated or tested by the c program, given a statement or statements to be executed if the condition is becomes true, and optionally, other statements to be executed if the condition is false.

Branching:
If refers to execute one of several possible options depending on the outcome of a logic, which is carried at some specific point within a c program.
:Example:
Nested if-else statement
if – else statement with in other if – else statement. Such statements are called nested if statements in c programming language.
if (expression1)
{
Execute if expression1 is true;
}
else if( expression2)
{
Execute if expression1 is false and 2 is true;
}
else if (expression 3)
{
Execute if text expression1 and 2 are false and 3 is true;
}

Else
{
Execute if all of the expressions are false;
}

exemple can be like this:

Tidak ada komentar:

Posting Komentar