Explain the working of break and continue statements in C-language with example.
Answers
Answered by
2
int main()
{
printf("break statement example");
for(int n=0;n>=0;n++)
{
if(n%2==0)
{
printf("\n%d ",n);
break;
}
}
printf("continue statement example");
for(int n=0;n>=0;n++)
{
if(n%3==0)
{
printf("\n%d ",n);
continue;
}
}
}
OUTPUT:
break statement example
2
continue statement example
3
6
9.......48
●In break statement ,the execution of the loop exit which satisfied the condition.
●In continue statement ,the execution of the loop continue either it not satisfied the condition (for a number 4 ,5.....)
Similar questions
English,
6 months ago
English,
6 months ago
Computer Science,
1 year ago
Biology,
1 year ago
Science,
1 year ago