If Statement
if statement is used when we want some part of program should be operated only if some conditinn is true. General form of if statement is if (Condition)Do this;
if (a==b)
printf("a and b are equal");
In above program a and b are equal is displayed only when a are equal to b.
If else statement
if(a==b)printf("a and b are equal");
else
printf("a and b are not equal");
If else if statement
if(a>80)
printf("Distionction");
else if (a>60 && a<80)
printf("First division");
else if(a<60 && a>40);
printf("Passed");
else
printf("Failed");
Nested if else
if()
{
if()
do this
else
do this
}
else if ()
{
if()
{
if()
do this
else
do this
}
else
do this
}
else
do this
The above is simple structure.
Next we will go to loop control structure do comment if you need help in some programs in your Lab assignment questions or class questions.
0 comments:
Post a Comment