Page 298 - CA_Blue( J )_Class9
P. 298
13 {
14 System.out.print(k+"\t");
15 k=k+1;
16 }
17 System.out.println(); //allows to print in the next line
18 }
19 }
20 }
You will get the following output:
Enter number of lines : 5
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
VARIABLE DESCRIPTION
NAME DATATYPE DESCRIPTION
n int Number of Lines
i int Loop Variable
j int Loop Variable
k int Variable to increase value one by one
Write a program to print the following structure
Program 20
5
45
345
2345
12345
1 class pattern2 // class name
2 {
3 public static void main()
4 {
5 int i,j; //Declaration of variable
6 i=5;
7 while(i>= 1) //Loop variable for number of lines
8 {
9 j=i;
10 while(j<= 5) //Loop variable for number of columns
296 Touchpad Computer Applications-IX

