Conditional statement
This is very simple.you face these problem daily.if you want to go to market and go to park .
But at a time you can go only one place either market or park.
In programming you also face these problems.
These are given below
1.if
2.if-else
3.if-else-if
4.nested if
If statement-
statement is execute when condition is true other wise it will terminated from loop.#include<stdio.h>
int main( )
{
if(condition)
{
statement;
}
}
FLOW CHART OF IF STATEMENT-
2.if-else statement-
general syntax of if-else statement-
#include<stdio.h>
int main( )
{if(condition)
{
statement1;
}
else
{
statement 2;
}
EXPLAINATION-
if condition true than statement 1 execute otherwise it will be terminated.
flow chart of if-else-
3.if-else-if
General syntax of if else if
#include<stdio.h>
int main( )
{if(condition1)
{
statement1;
}
else if(condition 2)
{
statement 2;
}
else
{ statement 3;
}
Explaination
if the condition1 is true than statement1 is execute or condition2 is true than statement2 is execute otherwise statement 3 will be execute.
flow chart-
flow chart-
4.nested-
general syntax of nested-
if (testExpression1)
{
statement1;
}
else if(testExpression2)
{
statement2;
}
else if (testExpression 3)
{
statement3;
}
else
{
statement4;
}



Comments
Post a Comment