Matrix Transpose Code in C#

This program illustrates how to find the transpose of a given matrix. 

Check C# Progamming Code below for details.



using System; using System.Text; using System.Threading.Tasks;

namespace Transpose_a_Matrix
{
    class Program
    {
        static void Main(string[] args)
        {
            int m, n, c, d;
            int[,] matrix = new int[10, 10];
            int[,] transpose = new int[10, 10];

            Console.WriteLine("Enter the number of rows and columns of matrix ");
            m = Convert.ToInt16(Console.ReadLine());
            n = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine("Enter the elements of matrix \n");

            for (c = 0; c < m; c++)
            {
                for (d = 0; d < n; d++)
                {
                    matrix[c, d] = Convert.ToInt16(Console.ReadLine());
                }
            }
            for (c = 0; c < m; c++)
            {
                for (d = 0; d < n; d++)
                {
                    transpose[d, c] = matrix[c, d];
                }
            }

            Console.WriteLine("Transpose of entered matrix");

            for (c = 0; c < n; c++)
            {
                for (d = 0; d < m; d++)
                {
                    Console.Write(" " + transpose[c, d]);
                } Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}