Home »
Ask & Discuss
»
Board Exams - CBSE, ICSE, State Boards
« Back to Discussion
Computer Science
Can anyone please give the code of the following program in JAVA.
1 2 3
2 3 4
2 3 5
The above array is a 2-D array.Now i want to print the sum of the numbers of each row just after the row
and the sum of each column just after each column like this:
1 2 3 6
2 3 4 9
2 3 5 10
5 8 12
I hope you understood.
I need the code of this program as early as possible.
2 Rates assured.
Comments (6)
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
i
if(i==2&&j<2)
a[i][j]=i+j;
else
if(i!=3&&j!=3)
a[i][j]=i+j+1;
else
if(i*j!=9){
for(k=0;k<3;k++)
{
if((i==3)
a[i][j]+=a[k][j];
else
if(j==3)
a[i][j]+=a[i][k];
}}}
print the array..
notice the relation betw the subscripts and no stored in them evrything will be clear ....hope this helps...
viraat how come a 4*4 hav index 4....also no element should be stored in [3][3] in ur case value of p is stored wat bout the rest of the elements?? now to the problem poser.....do u want me writ a pgm that stores the sum of each row or column...only???please clarify
Preparing for JEE?
Kickstart your preparation with new improved study material - Books & Online Test Series for JEE 2014/ 2015
@ INR 5,443/-

For Quick Info
Find Posts by Topics
Physics
TopicsMathematics
Chemistry
Biology
Institutes
Parents Corner
Board
Fun Zone
|
| 1. |
|
Bipin Dubey
|
| 2. |
|
Himanshu
|
| 3. |
|
Hari Shankar
|
| 4. |
|
edison
|
| 5. |
|
Sagar Saxena
|
| 6. |
|
Yagyadutt Mishr..
|









its okkkkkkkkkkkkkkkkkkkkkkkkkkkk
even if anyone gives the answer in C++ or C but please explain each step with comments