The if-else
statement in C is used to execute a block of code conditionally. The syntax is as follows:
Here, condition
is an expression that evaluates to true
or false
. If the condition is true
, the code inside the if
block is executed. If the condition is false
, the code inside the else
block is executed. The else
part is optional, and if not included, the program will simply skip the block if the condition is false.