# need coding for array

 Tweet
5 replies [Last post]
ash_rock
Offline
Last seen: 10 years 3 weeks ago
Joined: 2010-01-08
bOt Points: 114

i need coding for :

der is two dememsion array[3][3]

get the out put as ,

sum of each rows like this:

sum of row 1 =6000

sum of row 2=900

sum of row 3=400

bharathraj
Offline
Last seen: 10 years 11 weeks ago
Joined: 2010-01-04
bOt Points: 58
adding each rows of 2 dimensional arrays

for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
sum+=a[i][j];
}
cout<<i<<"rows sum:"<<sum<<endl;
sum=0;
}

iam not sure check out this

ash_rock
Offline
Last seen: 10 years 3 weeks ago
Joined: 2010-01-08
bOt Points: 114
i needv codin 4 it shashwant

i needv codin 4 it shashwant do it wen u come online

bharathraj
Offline
Last seen: 10 years 11 weeks ago
Joined: 2010-01-04
bOt Points: 58
while(j<3) {

while(j<3)

{

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

{

sum+=a[i][j];

}

cout<<sum;

j++;

}

is this right code?

shashwat
Offline
Last seen: 1 year 31 weeks ago
Joined: 2009-02-18
bOt Points: 1160
Adding each row of 2 dimensional arrays

Hi ash_rock,

Check out the code below -

#include <iostream.h>

int main()

{

int x[3][3]={{12,44,55},{34,7,10},{3,30,20}};

for(int i=0;i<3;i++)

{

int sum=0;

for(int j=0;j<3;j++)

sum+=x[i][j];

cout<<i<<" row sum: "<<sum<<endl;

}

return 0;