can someone help me how to make this one:

write a program using two-dimensional arrays that computes the sum of data in row and sum of data in column of the 3X3 array variable n[3][3].
sample output:

5 9 8 = 22
3 8 2 = 13
4 3 9 = 16
________
12 20 19

please help me, cause i want to pass my c language subject........

please help me, i have 2 days left. if i failed to submit this problem i can't pass my subject. please help me.

not: sorry for my bad english im a filipino

heres how this works: FIRST, you write your program, or at least part of your program. THEN, when it doesn't work, you come here and ask why doesn't such-and-such work, and show what you were trying to do. FINALLY, we will show you how to fix it and make it work.

here's how this *doesn't* work: you come here and ask people to write your program for you.

now you better get busy, time is running out.


EDIT: Okay, here's some hints

you have to declare your array variable like so:

int myArray[3][3];

where the first subscript is the row, and the second is the column. they will be indexed using the numbers 0, 1, and 2.

to add the three values in the first column together, you could do it like this:

temp_answer = myArray[0][0] + myArray[1][0] + myArray[2][0];

but rather than hard coding the script indices, you should rather make use of "for" loops.

heres how this works: FIRST, you write your program, or at least part of your program. THEN, when it doesn't work, you come here and ask why doesn't such-and-such work, and show what you were trying to do. FINALLY, we will show you how to fix it and make it work.

here's how this *doesn't* work: you come here and ask people to write your program for you.

now you better get busy, time is running out.


EDIT: Okay, here's some hints

you have to declare your array variable like so:

int myArray[3][3];

where the first subscript is the row, and the second is the column. they will be indexed using the numbers 0, 1, and 2.

to add the three values in the first column together, you could do it like this:

temp_answer = myArray[0][0] + myArray[1][0] + myArray[2][0];

but rather than hard coding the script indices, you should rather make use of "for" loops.

dude to be honest with you, i don't know how to write the program. this is my special project , and the key to pass my subject thats why i am looking for help. so that i can survive. you guys is my only hope. and one one more thing, honestly i hate this subject.

He's not asking you to be a good programmer. He is just asking that you make an effort first and then we will be glad to help.
Write the code the way that you think it should be written and then post the code and the errors.

1)declare the 2-d array say a[3][3].initialisation can be done like this

for(i=0;i<=2;i++)
{
        for(j=0;j<=2;j++)
        {
                   scanf("%d",&a[i][j]);
        }
}
/*to print the sum of row elements*/
for(i=0;i<=2;i++)
{        s=0;
        for(j=0;j<=2;j++)
        {
                  s=s+a[i][j];
                   printf("\t%d",s);
         }
}
/*to print the coloumn sum*/
for(j=0;j<=2;j++)
{        s=0;
       for(i=0;i<=2;i++)
      {
           s=s+a[i][j];
        }
}

pls see to it that you have properly declared the variables & initialised them.
i guess this code will work.iam not sure coz i havent run it .the logic is correct i guess

1) declare the 2-d array say a[3][3].initialisation can be done like this

for(i=0;i<=2;i++)
{
        for(j=0;j<=2;j++)
        {
                   scanf("%d",&a[i][j]);
        }
}
/*to print the sum of row elements*/
for(i=0;i<=2;i++)
{        s=0;
        for(j=0;j<=2;j++)
        {
                  s=s+a[i][j];
                   printf("\t%d",s);
         }
}
/*to print the coloumn sum*/
for(j=0;j<=2;j++)
{        s=0;
       for(i=0;i<=2;i++)
      {
           s=s+a[i][j];
        }
}

pls see to it that you have properly declared the variables & initialised them.
i guess this code will work.iam not sure coz i havent run it .the logic is correct i guess

a big thanks to you dude. i will try your codes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.