Example on the cycle for
In this case, both signals will sound 5 times
CODE:
for (int n=0; n <5; n ++)
{
beep (1000, 100);
beep (2000, 100);
}
{
beep (1000, 100);
beep (2000, 100);
}
In this case, everything that is after continue will be skipped.
CODE:
for (int n=0; n <5; n ++)
{
beep (1000, 100);
continue;
beep (2000, 100);
}
{
beep (1000, 100);
continue;
beep (2000, 100);
}
Example on the cycle while
In this case, the signal will sound five times
CODE:
int n=0;
while (n <5)
{
beep (1000, 100);
n ++;
}
while (n <5)
{
beep (1000, 100);
n ++;
}
In this case, n ++ will be skipped and there will be a closed loop
CODE:
int n=0;
while (n <5)
{
beep (1000, 100);
continue;
n ++;
}
while (n <5)
{
beep (1000, 100);
continue;
n ++;
}