Pattern 20 from Practice Question

not able to print diagonal element

Hey @amansinghc33 Sorry for the late reply. Can you specifically tell me what problem you are facing while printing diagonal elements.

//COndition to print diagonal elements is : 
//Top left to bottom right diagonal 
for(int i = 0; i < n; i++){
System.out.println(arr[i][i]);
} 
//Top right to bottom left
int j = 0;
for(int i = n - 1; i >= 0; i--){
System.out.println(arr[i][j]);
j++;
} 
1 Like

Thanks sir its done.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like