Thursday, 28 March 2013

Basic C# Program to multiply 2 Arrary 2*2 matrix (C sharp)


PROGRAM:

C# program to perfrom 2*2 matrix multiplication


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace matrix_multiplication
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, j;
            int[,] a = new int[2, 2]{{1,2},{1,2}};

            int[,] b = new int[2, 2]{{1,2},{1,2}};
 
           

            Console.WriteLine("Matrix multiplication is:");
            int[,] c = new int[2, 2];
            for (i = 0; i < 2; i++)
            {
                for (j = 0; j < 2; j++)
                {
                   
                   
                    c[i,j]=0;
                     for (int k = 0; k < 2; k++)
                     {
                         c[i, j] +=  a[i, k] * b[k, j];
                     }
                 }
            }
            for (i = 0; i < 2; i++)
            {
                for (j = 0; j < 2; j++)
                {
                    Console.Write(c[i, j]+"\t");
                }
                Console.WriteLine();
            }

            Console.ReadKey();
        }
    }

}




----------------------------- END -------------------------------------


OUTPUT 



Don't You Think this Awesome Post should be shared ??
| Basic C# Program to multiply 2 Arrary 2*2 matrix (C sharp) |
Back To Top Related Posts Plugin for WordPress, Blogger...