hussaindot_com

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

namespace Array_2
{
class Program
{
static void Main()
{
int i;
int[] c=new int[11];
int[] b=new int[11];
int[] a=new int[11];
for ( i = 0; i <= 10; i++)

//Console.WriteLine("Enter a Matrix1");

for ( i = 0; i <= 10; i++)

//Console.WriteLine("Enter  a Matrix2");

for (i = 0; i <= 10; i++)

c[i] = a[i] + b[i];

Console.WriteLine("The Addtion of Two Matrix is = {0}", c[i]);

}
}
}``````

Nick Evan 4,005

So what exactly is your question?

DanielGreen 6

hi!

First of all: what do you mean with matrix? For me, a matrix is int [][] and not int [] (this is for me a vector).

And in this line: this is only the addition of two values from the vector.

for (i = 0; i <= 10; i++)
c = a + b;

In this line, the value of "i" is 11 and your array is of a shorter dimension!!

Console.WriteLine("The Addtion of Two Matrix is = {0}", c);

By the way, if you want to make an output of the whole vector, this must be also inside the for-loop

``````for (i = 0; i <= 10; i++)
{
c[i] = a[i] + b[i];
Console.WriteLine("The Addtion of Row{0} is = {1}",i, c[i]);
}``````

Daniel

Geekitygeek 480

As DanielGreen said, i think there is some confusion about the meaning of a matrix. You are adding together two arrays.
Also, you have not enclosed your for loops in bracers. Unless you have a single line of code it is best to use bracers to ensure the correct code runs inside the loop.
Try this:

``````int i;
int[] c = new int[11];
int[] b = new int[11];
int[] a = new int[11];
for (i = 0; i < 10; i++)
{
Console.WriteLine("Enter next digit for Matrix 1");
//try converting to int, request new input if value not valid
{
}
}
for (i = 0; i < 10; i++)
{
Console.WriteLine("Enter next digit for Matrix 2");
{
}
}
for (i = 0; i < 10; i++)
{
c[i] = a[i] + b[i];
Console.WriteLine("The Addtion of Two Matrix at position {1} is = {0}", c[i], i);
}