Go Down

Topic: what sensor for DIY turbidimeter? (Read 626 times) previous topic - next topic

johnerrington

Quote
`for (int i=1;  i=3; i++) {`
says: set i = 1; set i=3; increment i.

you dont have a condition for the loop to end.  should you have i<=3?
I'm trying to help. If I find your question interesting I'll give you karma. If you find my input useful please give me karma (I need it)

wvmarle

This is an infinite loop:

Code: [Select]
for (int i=1;  i=3; i++) {
}


This is a loop that runs once or never, honestly not sure, I think it's never:

Code: [Select]
for (int i=1;  i==3; i++) {
}


This is a loop that runs two times, then quits:

Code: [Select]
for (int i=1;  i<3; i++) {
}



This way it runs three times:

Code: [Select]
for (int i=0;  i<3; i++) {
}


This way it also runs three times but the value of iterator i is one higher, so if you're working with arrays this method can land you in deep trouble:

Code: [Select]
for (int i=1;  i<=3; i++) {
}
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up