for Statement :
The for statement provides a compact and convenient repetition structure that
combines initialization, condition testing, and variable updating into a single
line. It is particularly well suited for counting loops where the number of
iterations is known.
The for statement provides a compact and convenient repetition structure that
combines initialization, condition testing, and variable updating into a single
line. It is particularly well suited for counting loops where the number of
iterations is known.
SYNTAX:
for (initialization; condition; update)
{
statements;
}
EXAMPLE:
#include <stdio.h>
int main() {
for(int i=0;i<=3;i++){
printf("Number: %d\n",i);
}
return 0;
}
EXAMPLE:
Number: 0
Number: 1
Number: 2
Number: 3