Page 212 - CA_Blue( J )_Class10
P. 212
16 v=v*(i-j+1)/j;
17 System.out.print(" "+v);
18 }
19 System.out.println();
20 }
21 }
22 }
Program 14 Write a program to draw the following pattern
1 import java.util.Scanner;
2 public class hourglass {
3 public static void main(String[] args) {
4 Scanner scanner = new Scanner(System.in);
5 System.out.println("Enter the number of rows for the pattern:");
6 int rows = scanner.nextInt();
7 for (int i = 0; i < 2 * rows - 1; i++) {
8 for (int j = 0; j < 2 * rows - 1; j++) {
9 if (i == 0 || i == 2 * rows - 2 || j == i || j == 2 * rows - 2
- i) {
10 System.out.print("@");
210210 Touchpad Computer Applications-X

