2d array entering value and sayings its a diagnol
Sure, here is an example of a 2D array in Python where we will enter values and then check if it is a diagonal matrix:
```python
# Function to check if a matrix is diagonal
def is_diagonal(matrix):
rows = len(matrix)
cols = len(matrix[0])
for i in range(rows):
for j in range(cols):
if i != j and matrix[i][j] != 0:
return False
return True
# Taking input for the 2D array
rows = int(input("Enter the number of rows: "))
cols = int(input("Enter the number of columns: "))
matrix = []
for i in range(rows):
row = []
for j in range(cols):
value = int(input(f"Enter the value at position ({i}, {j}): "))
row.append(value)
matrix.append(row)
# Printing the matrix
print("Entered Matrix:")
for row in matrix:
print(row)
# Checking if the matrix is diagonal
if is_diagonal(matrix):
print("The entered matrix is a diagonal matrix.")
else:
print("The entered matrix is not a diagonal matrix.")
```
You can run this code in a Python environment and enter the values for the 2D array. The code will then check if the entered matrix is a diagonal matrix or not.
Above is 2d array entering value and sayings its a diagnol.