Page 249 - CA_Blue( J )_Class9
P. 249
Program 3 Write a program to print the following pattern:
1 3 5 7 9
1 3 5 7
1 3 5
1 3
1
1 public class dowhile_pattern3
2 {
3 public static void main()
4 {
5 int start = 1;
6 int end = 9;
7 do {
8 int current = start;
9 int limit = end;
10 do {
11 System.out.print(current + " ");
12 current += 2;
13 } while (current <= limit);
14 System.out.println();
15 end -= 2;
16 } while (end >= 1);
17 }
18 }
You will get the following output:
Nested Loop 247

