-
Notifications
You must be signed in to change notification settings - Fork 0
/
Find the sum of row in matrix.txt
53 lines (48 loc) · 1.56 KB
/
Find the sum of row in matrix.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// user input number find the sum of row in matrix
Console.Write("Enter The Base Array Size : ");
int Row = int.Parse(Console.ReadLine());
Console.Write("Enter The Child Array Size :");
int Col = int.Parse(Console.ReadLine());
int[,] arr = new int[Row, Col];
int ptr;
int ctr;
ctr=0;
while (ctr<Row)
{
ptr = 0;
while (ptr<Col)
{
Console.Write("Enter The Value {0} :- ",(ctr+1));
arr[ctr, ptr] = int.Parse(Console.ReadLine());
ptr++;
}
ctr++;
Console.WriteLine();
}
int ctr1 = 0;
int ptr1;
while (ctr1<Row)
{
ptr1 = 0;
while (ptr1<Col)
{
Console.Write(" "+arr[ctr1,ptr1]);
ptr1++;
}
ctr1++;
Console.WriteLine();
}
Console.WriteLine();
for (int i = 0; i < Row; i++)
{
int Rsum = 0;
for (int j = 0; j < Col; j++)
{
Rsum = Rsum + arr[i, j];
}
Console.WriteLine("Sum Of Row "+(i+1)+" Element :"+Rsum);
}
Console.WriteLine();
}
}
}