How to exit a premature loop?
Answers
Answered by
2
Answer:
In a simple loop, the test expression is the sole factor that determines when the loop stops. When the test expression of a simple loop yields false, the loop terminates. However, as loops become more complex, we may need to arbitrarily terminate a running loop regardless of the value of the test expression. To do so, we use the break and continue statement.........
Answered by
1
An example:
int main()
{
for (int i=0;i<100;i++)
{
cout<<i<<endl;
break;
}
}
Output:
1
Similar questions
Math,
4 months ago
Economy,
4 months ago
Math,
9 months ago
Environmental Sciences,
9 months ago
Chemistry,
1 year ago