I am having a problem where the colsum[column] is just displaying junk data on the output, and I cannot seem to figure out why, if I put an output statement in the Computesums function for it outputs fine(just not the right place, this is fine, I was doing that for test). rowsum seems to be fine and working properly, just not colsum.

#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

void Computesums (int fisharr [] [4], int rowsum [], int colsum []);
//void Computeavg (int rowsum [], int colsum [], double rowavg [], double colavg []);


void main ()
{
	int row, column;
	int fisharr[6][4];
	int rowsum[6];
	int colsum[4];
	//double rowavg;
	//double colavg;
	ifstream FileIn;

	FileIn.open ("O:\\DATAFILE3.txt");

	cout << fixed << showpoint << setprecision(2);

	for(row = 0; row < 6; row++)
		for(column = 0; column < 4; column++)
			FileIn >> fisharr[row][column];

	
	Computesums (fisharr, rowsum, colsum);
	//Computeavg (rowsum, colsum, rowavg, colavg);


	cout << "******* The Oklahoma Fishery Laboratory *******\n\n";
	cout << "Lakes            Fish          Row Average";
	cout << endl;
	for(row = 0; row < 6; row++)
	{

		cout << row + 1 <<" ";
		
			for(column = 0; column < 4; column++)
			{
				
				cout << setw(6) << fisharr[row][column];
			}
					cout << setw(10) << rowsum[row]/6.0 << endl;
			
			
	}
	cout << setw(6) << colsum[column]/4.0 << endl;


}


void Computesums (int fisharr [] [4], int rowsum [], int colsum [])
{
	int row = 0;
	int column = 0;

	for (int row =0; row < 6; row++)
		rowsum[row] = 0;
	
	for (int row =0; row < 6; row++)
		for (int column = 0; column < 4; column++)
			rowsum[row] = rowsum[row] + fisharr[row][column];
		


	for (int column = 0; column < 4; column++)
		colsum[column] = 0;
	
	
		for (int column = 0; column < 4; column++)
			for (int row = 0; row < 6; row++)
			colsum[column] = colsum[column] + fisharr[row][column];
		
}





/*void Computeavg (int rowsum [], int colsum [], double rowavg [], double colavg [])
{
	int row = 0;
	int column = 0;
	
	rowavg = rowsum[row]/6;
	colavg = colsum[column]/6;



}*/

brb

brb

huh?

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.