For
รูปแบบการเขียนมีดังนี้
for(initialese counter;test counter;increment counter){
statement;
.
.
.
}
ตัวอย่างเช่น
for(int i=0;i<5;i++){
printf("HELLO WORLD.\n"):
}
จะทำการพิมพ์
HELLO WORLD
HELLO WORLD
HELLO WORLD
HELLO WORLD
HELLO WORLD
*-^หมายเหตุ
initialise counter หมายถึง ค่าเริ่มต้นของตัวนับจำนวนรอบ
test counter หมายถึง นิพจน์เงื่อนไขที่กำหนดไว้
increment counter หมายถึง ค่าที่เพิ่มขึ้นของตัวนับจำนวนรอบ
