2times
This is equivalent to the for loop
z = 0;
while (z <= 1) //note that z starts with a value less than 1
{
//do stuff
z++;
}
How many times will the while loop execute the //do stuff code
is there a way to break the loop when i press the button when the loop is running?
You could read the button pin inside the for loop then use a break; statement to exit the for loop when the button becomes pressed, but that would be regarded by many as an inelegant solution to the problem.