for循环是一种重复控制结构,它允许您高效地编写需要执行特定次数的循环。
C编程语言中for循环语法是-
for ( init; condition; increment ) { statement(s); }
#include <stdio.h> int main () { int a; for( a=10; a < 20; a=a + 1 ){ printf("value of a: %d\n", a); } return 0; }
编译并执行上述代码时,将生成以下结果-
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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)