Q17'
Q17'
1. Start
2. Input:
o Get the size of the matrix (n) from the user.
o Get the replacement number (x) from the user.
3. Initialization:
o Create a 2D integer array a of size n x n to store the matrix elements.
4. Input Matrix Elements:
o For each row i from 0 to n-1:
For each column j from 0 to n-1:
Get the element a[i][j] from the user.
5. Modify Diagonals:
o For each row i from 0 to n-1:
For each column j from 0 to n-1:
If i == j (primary diagonal) or i + j == n - 1 (secondary diagonal):
Replace a[i][j] with x.
6. Output:
o Print the original matrix a.
o Print the modified matrix a (with diagonals replaced).
7. End