So I was just trying out this question, just wanted some help in the code, I am not able to identify the problem here, so this is the question
Write a program in Java, to input a 2 dimensional array to generate a Pascal's triangle, it should specifically look like this
1
11
121
1331
14641
So here is my java program for this question:
public static void main(int row) {
int Arr[] = new int[row][row];
int i = 0, j = 0;
for (i = 0; i <= row; i++) {
for (j = 0; j <= row; j++) {
Arr[j] = Arr[i] + 1;
}
}
}
I don't really know where to start, I tried using the logic that if taken for a square matrix then the upper two will sum up to the lower one, but I don't really think my logic is valid here, because I did many mistakes in the logic, I just don't know how to make this one, I have no problem in the printing part, so I omitted that from the program.