I need help adding the data in columns and rows of 10 in a 2d array. I got the rows added, but could someone please help out with how to sum the data in the columns. Please look at my code, and thanks in advance
#include <iostream> // I/O TO DOS SCREEN
#include <fstream> // FILE I/O
#include <stdlib.h> // STANDARD LIBRARY
#include <iomanip> // I/O FORMATTING
using namespace std;
//
// PROTOTYPE STATEMENTS
//
void function_name();
//
// GLOBAL VARIABLE DECLARATIONS
//
const int SIZE = 10;
float sum = 0;
int main()
{
int two_di_arr[ SIZE ][ SIZE ];
ifstream infile("Two_Dimensional_Data_In.txt");
for( int row = 0; row < SIZE; row++ )
{
for( int col = 0; col < SIZE; col++ )
{
infile >> two_di_arr[ row ][ col ];
sum += two_di_arr[ row ][ col ]; //This is where I sum the rows
cout << setw( 6 ) << two_di_arr[ row ][ col ] << " ";
}
cout << sum / SIZE;
cout << endl;
}
system("pause");
return 0;
}
// END MAIN() //////////////////////////////
// FUNCTION DEFINITIONS
void function_name()
{
}
////////////////////////////////////////////
Code tags added. -Narue