Solved

# how sum of each row 2D array [3,6]

Posted on 2011-10-07
253 Views
Write c# programming to the following:
-Initialize two D –array [3,6].
-sum of each row and print the result.
-multiplication of each columns and print the result.
-print out the array as following.
output :
1                   2             3               4               5               6  sum=   21
2                   6             5               4               9               7  sum=  33
8                   7             6               5               9               0  sum=  35
m=   16       m=  84     m=90      m=  80    m= 405     m= 0
0
Question by:myaspnet

LVL 12

Accepted Solution

Here you go:

``````            // read the values from the user
for (int i = 0; i < 3; i++)
{
Console.WriteLine("Enter the values for row " + i.ToString() + " ...");
for (int j = 0; j < 6; j++)
{
}
Console.WriteLine("\n\n");
}

//print the values alont with the sum and product
for (int i = 0; i < 3; i++)
{
int sum = 0;
for (int j = 0; j < 6; j++)
{
}
//write the sum for each row
Console.Write("Sum = " + sum.ToString());
Console.WriteLine("");
}
for (int j = 0; j < 6; j++)
{
int prod = 1;
for (int i = 0; i < 3; i++)
{
}
Console.Write("M = " + prod.ToString() + "\t");
}

//write the products for each column

//pause to view result
Console.WriteLine("\n\n\nPress Enter to Exit...");
``````

Output will show as follows:

``````Enter the values for row 0 ...
1
2
3
4
5
6

Enter the values for row 1 ...
3
4
5
6
7
8

Enter the values for row 2 ...
1
1
1
1
1
1

1       2       3       4       5       6       Sum = 21
3       4       5       6       7       8       Sum = 33
1       1       1       1       1       1       Sum = 6
M = 3   M = 8   M = 15  M = 24  M = 35  M = 48

Press Enter to Exit...
``````
0

LVL 1

Author Comment

thank you very mach..
0

LVL 1

Author Closing Comment

thanks
0

## Featured Post

### Suggested Solutions

Visual Studio and sql server data tools 4 30
Detect file exist or not 3 43
WPF issue with Trigger 2 31
Linux operating system 12 30
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
how to add IIS SMTP to handle application/Scanner relays into office 365.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.