Home →C Programming Language →C Control Flow
if-else-if Statement
If we want to use several conditions we can use if-else-if statement. Here are common syntax of if-else-if statement:
if(condition-1)
{
/* code block if condition-1 is true */
}else if (condition-2){
/* code block if condition-2 is true */
}else if (condition-3){
/* code block if condition-3 is true */
}else{
/* code block all conditions above are false */
}
And source code example:
if(x == y)
{
printf("x is equal y");
}
else if (x > y){
printf("x is greater than y");
}else if (x < y){
printf("x is less than y");
}
