Code help understand

What does this code do ?
for(i = 0; i < something; i++){

2 Answers

2

It runs the loop something times…

For example, lets do this:

for(int i = 0; i<100; i++) {
print (i);
}

That will print every number from 0 to 100.

for(int i=1; i<=100; i++) {
print (i);
}

This will print 1 to 100. Notice I included the = to the <=.

You can imbed method calls to other functions if you wish to.

for(int i=0; i<10; i++) {
if(i==1){
functionA();
} else if(i==5) {
functionB();
} else {
functionC();
}
}