只要给定条件为真,D编程语言中的while循环语句就会重复执行目标语句。
D编程语言中while循环语法为-
while(condition) { statement(s); }
import std.stdio; int main () { /* 局部变量定义 */ int a=10; /* while循环执行 */ while( a < 20 ) { writefln("value of a: %d", a); a++; } return 0; }
编译并执行上述代码时,将生成以下结果-
链接:https://www.learnfk.comhttps://www.learnfk.com/d-programming/d-programming-while-loop.html
来源:LearnFk无涯教程网
value of a: 10 value of a: 11 value of a: 12 value of a: 13 value of a: 14 value of a: 15 value of a: 16 value of a: 17 value of a: 18 value of a: 19
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)