C语言 if语句
if语句由一个布尔表达式后跟一个或多个语句组成。
if语句 - 语法
C编程语言中‘if’语句的语法是
if(boolean_expression) {
/* statement(s) will execute if the boolean expression is true */
}
if语句- 流程图
if语句 - 示例
#include <stdio.h>
int main () {
/* local variable definition */
int a=10;
/* check the boolean condition using if statement */
if( a < 20 ) {
/* if condition is true then print the following */
printf("a is less than 20\n" );
}
printf("value of a is : %d\n", a);
return 0;
}
编译并执行上述代码时,将生成以下结果:
a is less than 20;
value of a is : 10