Home | Computer Science

<
FOR LOOP

Defination

A "For" Loop is used to repeat a specific block of code a known number of times.


FOR LOOP Syntax of for loop is
for (statement 1; statement 2; statement 3) {
// code block to be executed
}
For Loop
1. Statement 1 is executed (one time) before the execution of the code block. 2. Statement 2 defines the condition for executing the code block. 3. Statement 3 is executed (every time) after the code block has been executed
Program
INPUT

#include <stdio.h> main() { int i; for (i = 0; i <= 10; i = i + 2) { printf("%d\n", i); } }

OUTPUT