If-else statement in C.
Friends now we are Going To start If-Else.
Some time we have to make some decision in our program for those we have If statement. If statement work in such a way
1.
if (condition)
statement;
if our condition is true then our statement will run
2.
if (condition)
statement_1;
else
statement_2;
In this case if our condition is true then our statement_1 will run and if our condition is false then our statement_2 will run.
3.
if (condition)
{
statement_1;
statement_2;
statement_.....;
}
else
statement_n;
In this case if our condition is true then all our statements written in if ( or we can say all statement in that pair of {} ) will run .
NOTE : If we have more than one statement than pair of {} is necessary.
If our condition is false then our statement_n will run. which was written in else.
3.
if (condition)
{
statement_1;
statement_2;
statement_.....;
}
else
{
statement_1;
statement_2;
statement_.....;
}
In this case if our condition is true then all our statements written in if ( or we can say all statement in that pair of {} after if ) will run .
If our condition is false then our all statements written in else will run. which was written in else. ( or we can say all statement in that pair of {} after else ) will run .
NOTE : If we have more than one statement than pair of {} is necessary.
In our next Post we will code some programe. Based on If-else statements and do some example.