Break statement: The break statement is used to break control in the loops. Or in general statement it is used to break the sequence. In switch case, break is used to break control of switch it self when the selected case gets executed.
EXAMPLE OF BREAK
#include<stdio.h>
void main()
{
int num1,num2,sum;
int option;
switch(option)
{ case 1:
sum=num1+num2;
break;
case 2:
sum= num1 * num2;
break;
}
}
Continue statement: The continue statement is used to transfer the control in the beginning of loop. Whenever the continue statement is encountered immediately the control passes to the beginning of the loop. Continue is generally used with if-else statement.
EXAMPLE OF CONTINUE
#include <stdio.h>
int main () { int a = 10; do { if( a == 15) { a = a + 1; continue; } cout << "value of a: " << a << endl; a = a + 1; }while( a < 20 );
return 0; }
Anuncio publicitario
En este articulo:break and continue,break statement,break statements,continue statement,continue statements,oop,programming in c,TCL statements in C,transfer statements,tutorial
Escrito por
Krish Advani
Administrador de ENGGDRCAOS. Canal dedicado especialmente a la formación del estudiante que aspira a ser ingeniero. Todos los videos son Ingles. Apasionado del universo Apple, estudiante de Ingeniería y Gamer por vocación.
