I need help with a printData function to output my code to an output file.
Ive tried you can see one of my attempts commented out.

#include<fstream>
#include <iostream>

using namespace std;

//functions
void getData(ifstream& ,ofstream&, int temperature[2][12]);
float avgerageHigh(int temperature[2][12]);
float avgerageLow(int temperature[2][12]);
int indexHighTemp(int temperature[2][12]);
int indexLowTemp(int temperature[2][12]);
// printData (ofstream& outputFile, int temperature[0][high], int avghigh, int temperature[1][low], int avglow);


void main()
{
	float avghigh;
	float avglow;
	int temperature[2][12];                    
	int high=0;
    int low=0;

	
	
	ifstream inputFile;
    ofstream outputFile;

    //gets data from file
	getData(inputFile,outputFile,temperature);
    
	//high and low temperatures
	high=indexHighTemp(temperature);
	low=indexLowTemp(temperature);

	//average temperatures
	avghigh=avgerageHigh(temperature);
	avglow=avgerageLow(temperature);
   
	//outputs to file
    outputFile<<"Highest: "     <<temperature[0][high]<<endl;
    outputFile<<"Average high: "<<avghigh<<endl;
	outputFile<<"Lowest : "     <<temperature[1][low]<<endl;
    outputFile<<"Average Low: " <<avglow<<endl;	

   // printData (ofstream& outputFile, temperature[0][high],avghigh,temperature[1][low],avglow);

   
}

void getData(ifstream& inputFile,ofstream& outputFile, int temperature[2][12])
{
	
	int col=0;
	int row=0;

    //opens files
	inputFile.open("input.txt");
	outputFile.open("output.txt");


	if(!inputFile.is_open())
	{
		cout << "Unable to open input file!" << endl;
		return;
	}


	for(row=0;row<=11;row++)
	{
		for( col=0;col<=1;col++)
		{
			inputFile>>temperature[col][row];
		}		
	}


for(row=0;row<=11;row++)
	{
		for( col=0;col<=1;col++)
		{
			cout<<temperature[col][row]<<" ";
		}	cout<<endl;	
	}

    // close files
	inputFile.close();
    outputFile.close();

    cout << "Results processed and saved in output.txt" << endl;
}

float avgerageHigh(int temperature[2][12])
{

	int col=0;
	int row=0;
	int sum=0;

	
	for( row=0;row<=11;row++)
	{
		sum=sum+temperature[col][row];
	}		
	//returns average high temperature	
	return sum/12;	
}



float avgerageLow(int temperature[2][12])
{

	int col=1;
	int row=0;
	int sum=0;

	
	for( row=0;row<=11;row++)
	{
		sum=sum+temperature[col][row];
	}		
	
    // returns the average low
	return sum/12;
}


int indexHighTemp(int temperature[2][12])
{
	
	int col=0;
	int row=0;
	int tempHigh = 0;
    int indexTemp=0;
	
	for( row=0;row<=11;row++)
	{
		if(temperature[col][row] > tempHigh) 
		{
			tempHigh=temperature[col][row];		
			indexTemp=row;	
		}
	}
	
	
	
    //returns the highest index
	return indexTemp;
}

int indexLowTemp(int temperature[2][12])
{
	
	int col=0;
	int row=0;
	int tempLow=999;
	int indexTemp=0;

    col=1; 

	
	for( row=0;row<=11;row++)
	{
		if(temperature[col][row]<tempLow) 
		{
			tempLow=temperature[col][row];		
			indexTemp=row;	
		}
	}		
	
    //returns the lowest index
	return indexTemp;
}
Comments
Use code tags.
return sum/12;

Do you want an integer result? Or a float with the fraction not truncated?

return sum/12.0F;

(This seems to be a recurring theme lately.)

This article has been dead for over six months. Start a new discussion instead.