在BC中,使用IF语句来执行条件判断。语法为:
IF condition THEN {statement block 1} [ELSE {statement block 2}] END;
其中,condition是一个布尔表达式,如果为True则执行statement block 1,否则执行statement block 2。
例如:
IF Quantity > 10 THEN MESSAGE('Quantity greater than 10.'); ELSE MESSAGE('Quantity less than or equal to 10.'); END;
这个例子中,如果Quantity大于10,则输出“Quantity greater than 10.”,否则输出“Quantity less than or equal to 10.”。
上一篇:bc是否不会限制变量的作用域?