Page 244 - CA_Blue( J )_Class9
P. 244
4 { int i ,j;
5 for(i=5;i>=1;i=i-1)
6 { for(j=1;j<=i;j++)
7 { System.out.print(j); }
8 if(i==3)
9 break;
10 System.out.println();
11 }
12 }
13 }
You will get the following output:
In the above program, when the value of “i” is 3, the condition is true and the break statement is executed which
results in the control coming out of the outer loop. Similarly, we can use a break statement in the inner loop, which
will make the control exit the inner loop and the outer loop executes again.
Program 5 Using break statement in the inner Loop.
1 class innerloop_break
2 {
3 public static void main()
4 { int i ,j;
5 for(i=5;i>=1;i--)
6 { for(j=1;j<=i;j++)
7 { if(i==3)
8 break;
9 System.out.print(j); }
10 System.out.println();
242 Touchpad Computer Applications-IX

