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
Social Sciences,
4 months ago
Biology,
4 months ago
Math,
4 months ago
Math,
8 months ago
Environmental Sciences,
8 months ago
Chemistry,
11 months ago
Social Sciences,
11 months ago