This is my problem. I am taking a class that is designed to be an independant study and the book only touches on the surface of the ideas covered. this code is a project that i am stuck on and cant really find any help anywhere else so i am hoping that someone can help me figure out what is wrong and what is missing. this is supposed to take a 3X3 array of numbers and add them into colums and rows on the 4th row and line, then have a sum in [4][4]. i know the code is missing the 4th colum (which i am kinda confused on how it should be written) and also, the program is summing the 4th row then re-adding it to the total (basically doubling the solution). i will ve extremely greatful for any and all help on this. thank you.

#include <stdio.h>

#include "stdafx.h"

int

main(void)

{

int array[4][4]={0};

int i, j;

int sum;

printf (

"Please enter the numbers you wish to be added (with a space between each number)\n");

printf (

"when all numbers are entered, press enter to \n calculate each row and columns totals\n");



for

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

for

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

scanf_s("%d", &(array[i][j]));



for     (i = 0; i < 4; ++i){



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

          {array[3][j]+= array[i][j];


           printf("%d\t",array[i][j]); }


     printf("\n");}



return 0;

}

Think this is more likely the calculations.

I added a func to print the array to keep it simple.

#include "stdafx.h"
#include <stdio.h>

void PrintArray(int arr[][4], int rows, int columns){

    for (int y = 0; y < rows; y++) {

        for (int x = 0; x < columns; x++) {

            printf("%d\t", arr[y][x]);

        }
        printf("\n");
    }
    printf("\n");
}


int _tmain(int argc, _TCHAR* argv[])
{

    int narray[4][4]={0};

    int i, j;

    int sum;

    printf ("Please enter the 9 numbers you wish to be added (with a space between each number)\n");

    printf ("when all numbers are entered, press enter to \n calculate each row and columns totals\n");

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

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

            scanf_s("%d", &(narray[i][j]));


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

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

            narray[i][3] += narray[i][j];
            narray[3][i] += narray[j][i];
        }

    }

    PrintArray(narray, 4, 4);

    return 0;
}

There is of course a last calculation which I will leave to yourself.

Suzie, you are amazing. Your code was so much easier to make sense of what was going on. The narray[3][3] part was simple once i was able to go through each step and see what was what. Btw, it says you are using VS 2010 (unless i am reading it wrong). if so, the lnk4475 error, do you know of any way to get rid of this for good so i dont have to go back each time and disable it?

Sorry, I don't receive such error or warning.

Cannot find anything about it in search either.

see the error description, most likely there's a problem in your project setup that causes it to not find something during the link phase.

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.