Answer to Question #299574 in C# for kzhm

Question #299574

Create a program that will transpose the elements (values) of a 16-element two-

dimensional integer array (4x4) Transpose. The value of each element should be obtained


from the user (or inputs).

For example:

Original Entries Transposed Entries

1 2 3 4 1 5 9 3

5 6 7 8 2 6 0 4

9 0 1 2 3 7 1 5

3 4 5 6 4 8 2 6


1
Expert's answer
2022-02-18T12:50:39-0500
using System;

namespace transp
{
    class Program
    {
         static void Main()
         {
           int[,] transpose = 
           {
                 {1,2,3,4},        // From example 
                 {5,6,7,8},
                 {9,0,1,2},
                 {3,4,5,6}
            };
        
           for (int i = 0; i < 4; i++)
           {
                for (int j = 0; j < 4; j++)
                {
                   Console.Write("{0} ", transpose[i, j]);
                }
                for (int j = 0; j < 4; j++)
                {
                   Console.Write("{0} ", transpose[j, i]);
                }
                Console.WriteLine();
                Console.WriteLine();
            }
             Console.WriteLine();
             Console.Write("Press any key to exit. . . ");
             Console.ReadKey(true);
        }      
     }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS