C Programming Code Examples C > Beginners Lab Assignments Code Examples Program Code - else..if statement Program Code - else..if statement The else..if statement is useful when you need to check multiple conditions within the program, nesting of if-else blocks can be avoided using else..if statement. 1. else and else..if are optional statements, a program having only "if" statement would run fine. 2. else and else..if cannot be used without the "if". 3. There can be any number of else..if statement in a if else..if block. 4. If none of the conditions are met then the statements in else block gets executed. 5. Just like relational operators, we can also use logical operators such as AND (&&), OR(||) and NOT(!). #include <stdio.h> int main() { int j1, j2; printf("Input the value of j1:"); scanf("%d", &j1); printf("Input the value of j2:"); scanf("%d",&j2); if (j1 !=j2) { printf("j1 is not equal to j2\n"); } else if (j1 > j2) { printf("j1 is greater than j2\n"); } else if (j2 > j1) { printf("j2 is greater than j1\n"); } else { printf("j1 is equal to j2\n"); } return 0; }