We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c050653 commit 59da9cdCopy full SHA for 59da9cd
Assignment-4/PascalTriangle.java
@@ -0,0 +1,35 @@
1
+/*
2
+ * PROGRAM : To generate the Pascal traingle pattern
3
+ * FILE : PascalTriangle.java
4
+ * CREATED BY: Santosh Hembram
5
+ * DATED : 14-09-20
6
+ */
7
+import java.util.*;
8
+class PascalTriangle {
9
+
10
+ public static void main(String[] args) {
11
12
+ Scanner sc = new Scanner(System.in);
13
+ System.out.print("Enter the number of rows: ");
14
+ int row = sc.nextInt();
15
16
+ int space = row;
17
+ int number = 1;
18
19
+ for (int i=0; i<row; i++ ) {
20
21
+ for (int s=1; s<=space; s++ ) {
22
+ System.out.print(" ");
23
24
+ }
25
+ number = 1;
26
+ for (int j=0; j<=i; j++ ) {
27
+ System.out.print(number+" ");
28
+ number = number * (i-j)/(j+1);
29
30
31
+ space--;
32
+ System.out.println();
33
34
35
+}
0 commit comments