Flow Control - LucasMW/mongaComp GitHub Wiki
Flow Control
if clause:
if(condition) {
//do something if condition is true
}
if else clause:
if(condition) {
//do something
}
else {
//do something else
}
while clause:
while(condition) {
//do something
}
while is used to make loops. an example:
//sum of array
float sum;
sum = 0;
int i;
i = 0;
while(i<10) {
sum = sum + fArray[i];
i = i + 1;
}
@"Sum is : "@sum; @"\n";
Note that if the line
i = i + 1;
is removed, the loop would be stuck because i<10 would always result true,
thus resulting into an infinite loop.