If-Else Condition:


How if statement works:



The if-else condition’s statement works ,when our given condition (  ) are

true, then our compiler goes into the if statement. But when it is false ,

then if conditions block will be skipped normally. Block is the braces

{ }. And it goes to else statement.


Logic in flow Chart:







Example:



#include<stdio.h>
int main(){
int a=8;
int b=6;
    if(a>b){
        printf("Yes");
    }else{
        printf("Sorry Not");
    }
}


Note:


If we don't use {} our code will execute the next one single statement.

And if conditions will not make a block. Block will create when

we use curly braces {   }



More example from GitHub: Click here


10 exercise of this topics:



Post a Comment

Previous Post Next Post