Friday, August 1, 2008
#include
#define NUMOFREADINGS 5 //This makes your program scale-able, more readings can be added.
using namespace std;
//function prototypes
void entry(double temp[]);
void display (double temp[]);
void avg_Temp (double temp[], double averageTemp);
double temp[NUMOFREADINGS], averageTemp;
int main()
{
double temp[NUMOFREADINGS];
cout << "Room Temperature Analysis" << endl;
cout << "=========================" << endl << endl;
entry(temp); // Call function to allow user to enter the readings
display(temp);
avg_Temp(temp, averageTemp);
return 0;
}
// Your functions here
void entry (double temp[])
{
int i;
for (i = 0; i < NUMOFREADINGS; i++)
{
cout << "Enter temperature: ";
cin >> temp[i];
}
return ;
}
void display (double temp[])
{
int i;
cout << endl << "You have entered the folllowing readings: ";
for (i = 0; i < NUMOFREADINGS; i++)
{
cout << temp[i];
if (i+1 < NUMOFREADINGS)
{
cout << ", ";
}
}
return ;
}
void avg_Temp (double temp[], double averageTemp)
{
double total_Temp = 0;
int i;
for (i = 0; i < NUMOFREADINGS; i++)
{
total_Temp += temp[i];
}
averageTemp = total_Temp / NUMOFREADINGS;
cout << endl << endl << "Average temperature is : " << averageTemp << endl;
return ;
}
try
; tortured on 10:56 PM =/
__________________________________
the1B02
ONE class of FIFTEEN gentlemen and FIVE ladies
average age of SEVENTEEN
first met each other on 8th apr 08 at T1442
we are
environmental friendly
theCREWS
Designer: no idea
Code Edited: abigail/han sheng
Picture: photobucket
Host: blogger::
photobucket
Thanks: blogskins
click THIS: ♥
thecopyCATS
this blog was created by HANSHENG.
the templater was ABIGAIL.
blogskin found by JESSLE.
you are NOT ALLOWED to copy or take anything from HERE. trespassers WILL be prosecuted.