Beruflich Dokumente
Kultur Dokumente
FOR LOOP
Academic Resource Center
Or
*
**
***
****
*****
******
*******
********
*********
System.out.println("*");
System.out.println("**");
System.out.println("***");
System.out.println("****");
System.out.println("*****");
System.out.println("******");
System.out.println("*******");
System.out.println("********");
System.out.println("*********");
System.out.println("**********");
for(int i = 0; i< 10; i++){
for(int j = 0; j<i; j++){
System.out.print("*");}
System.out.println(); }
Statement 1
Declare and initial the counter
I.e.
Int I;
i = 0;
Statement 2
A Boolean expression to check the condition:
I.e.
I < 10;
I >= 100;
Increment
i.e.
i++;
i+= 5;
i+= 10;
}
C/C++: int I;
Result:
Result
For ( ; ; ){
}
For loop with one condition:
For (; input == q ;){
}