-->

neb39:Differentiate between break and continue with example

Differentiate between break and continue with example
ans:
differences are :

break
continue
1
It terminates the execution.
It takes the iteration to next level(skipping).
2
It can be used in loop and switch.
It can be used in switch
3
It uses keyword ‘break’.
It uses keyword ‘continue’.
4
Its syntax is
break;
Its syntax is
continue;
5
Example is
For(i=1;i<=4;i++)
{
  If(i<=2)
    Printf(“%d\n”,i);
     Break;
}
}
Example is
For(i=1;i<=4;i++)
{
  If(i<=2)
    Printf(“%d\n”,i);
     continue;
}
}

output is:1 
output is:1,2

No comments:

Post a Comment