if 语句的一般形式或语法
if (expression)
{
Statement 1;
}
Next_statement;
if-else
if (expression)
{
Statement 1;
}
else
{
statement 2;
}
Next_statement;
使用语句块
if (expression)
{
Statement A1;
Statement A2;
...
}
else
{
statement B1;
Statement B2;
...
}
Next_statement;
嵌套的if语句
if (expression1)
{
Statement A;
if (expression2)
{
StatementB;
}
else
{
StatementC;
}
}
else
{
statement D
}
Next_statement;
条件运算符的表达式的一般形式
condition ? expression 1 : expression 2