A few days back someone asked me a question via email which I thought might be useful to others too. So I’m listing that question along with its answer below. Q. I want to write a program such that users enter the value of matrix and each operation (listed below) is performed by functions. I want to use switch structure to call the functions. 1. Rotate the matrix around the diagonal. Example: 1 2 3 ---> 1 4 7 4 5 6 2 5 8 7 8 9 3 6 9 2. Rotate the matrix around the middle row. Example: 1 2 3 ---> 7 8 9 4 5 6 4 5 6 7 8 9 1 2 3 3. Rotate the matrix around the middle column. Example: 1 2 3 ---> 3 2 1 4 5 6 6 5 4 7 8 9 9 8 7 4. Set the upper triangle to zero. Example: 1 2 3 ---> 1 0 0 4 5 6 4 5 0 7 8 9 7 8 9 Ans. The following program does it. Please note that the matrix is declared as global so as to reduce complications in the program. Better way should have been t...
A resource for learning PHP, HTML, CSS, JavaScript, C++, etc.