2) Continue: -
The continue statement is used for inverse operation of the
break statement. The continue statement transfer control to start of loop.
Syntax: -
continue;
Example: -
//Write a program using continue
class table
{
public static void main(String args[])
{
int i, n = 4;
for(i=1;i<=10;i++)
{
if(i==3)
continue;
System.out.println(n +"*" + i +"="+
n*i);
}
}
}
OUTPUT
4*1=4
4*2=8
4*3=12
4*4=16
4*5=20
4*6=24
4*7=28
4*9=32
4X10=32
3) Break: -
Break statement is used to terminate the loops(for, while,
do while etc)
Syntax: -break;
Example: -
//Write a program to use break
class table
{
public static void main(String args[])
{
int i, n = 4;
for(i=1;i<=10;i++)
{
if(i==3)
break;
System.out.println(n +"*" + i +"="+
n*i);
}
}
}
OUTPUT
4*1=4
4*2=8
Case Control Staement
No comments:
Post a Comment