Home C Programming Language C Control Flow

if-else Statement

In case you want to use both condition of if statement, you can use if-else statement. If the condition of if statement is false the code block in else will be executed. Here is the syntax of if-else statement:

if(condition){
  /* code block of if statement */
}else{
  /* code block of else statement */
}

And code example:

if(condition){
  /* code block of if statement */
}else{
  /* code block of else statement */
}