if else Statement in C - if-else if (ladder if) in C Program



 if else if (ladder if) in C Program

Learn c - c tutorial - if else if (ladder if) in C Program - c examples - c programs

if else if (ladder if) in C Program

  • The if/else-if Ladder conditional expressions are evaluated from the top downward.
  • As soon as a true condition is found, the statement related to it is executed, and the remainder of the ladder is by passed.
  • If the conditions are true and then the final else statement are executed.

Sample Code

#include <stdio.h>
int main()
{
    int a=-20;
    if(a>0)
        printf("%d is a Postive Integer\n",a);
    else if(a<0)
        printf("%d is a Negative Integer\n",a);
    else
        printf("Its ZERO\n");
    return 0;
}

Output

-20 is a Negative Integer


View More Quick Examples


Related Searches to if else Statement in C - if-else if (ladder if) in C Program