This is an assignment given to me with the worst possible book for this class. Basically, i need this code to add the row and col of the user input. i know it is missing the row portion, but currently, the col addition is summing everything together twice and i dont see why. The teacher wont help me because the class is a "self taught" class, however, i need this to pass the class.

// test 2.cpp : Defines the entry point for the console application.

#include <stdio.h>

#include "stdafx.h"




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");


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


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

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

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

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

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

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


return 0;


Hi new2code welcome here at DaniWeb.
Many issues here.
Is this a C or C++ program, as it is it is C.
Start by writing line 42 and 43 on one line and change the 4 into a 3.
Like this:
for (i = 0; i < 3; ++i){
BTW, you should have posted this on the C or C++ forum here, to get more respons.

thanks for replying

it was a c code, and i ended up putting it into the c area. your suggestion eliminated the sum of the 4th row which is actually where the main issue i am having was. for some reason, the 4th row was doing the summing correctly, then re reading the line and adding itself to the total again. as if the answer to the first spot in the fourth row was 12, it is adding 12 to it again and making it 24.

This question has already been answered. Start a new discussion instead.