Home →C Programming Language →C Control Flow
if Statement
if statement is a basic control flow structure of C programming language. if statement is used when a unit of code need to be executed by a condition true or false. If the condition is true, the code in if block will execute otherwise it does nothing. The if statement syntax is simple as follows:
if(condition){
/* unit of code to be executed */
}
C programming language forces condition must be a boolean expression or value. if statement has it own scope which defines the range over which condition affects, for example:
/* all code in bracket is affects by if condition*/
if(x == y){
x++;
y--;
}
/* only expression x++ is affected by if condition*/
if(x == y)
x++;
y--;
