Hey guys
Need help with the following program. I keep getting compilation error
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
Apparently I am not able to pass by reference however it works well when I pass by value.
The assignment requires a pass by reference function or I would just do pass by value.
My dilemma is how do I call the pass by reference function properly.
I am desperate. Please help anyone!
#include "stdafx.h"
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
#include <iomanip>
using std::setw;
using std::setprecision;
using std::fixed;
float cent(float); // function prototype (pass by value)
void fahren(float &); // function prototype (pass by reference)
// function main begins program execution
int main()
{
float centi = 0;
float fah = centi;
// displays table information
cout << setw(25) << "Centigrade to Fahrenheit" << setw(30)
<< setw(35) << "Fahrenheit to Centigrade" << endl << endl;
// two tables are created
cout << setw(8) << "Centigrade" << setw (16) << "Fahrenheit" // table for centigrade to fahrenheit
<< setw(18) << "Fahrenheit" << setw(16) << "Centigrade"; //table for fahrenheit to centigrade
cout << endl;
for (float i = 0; i <= 100; i+= 5)
{
centi = i;
for (float j = 0; j <= 5; j+= 25)
cout << setw(6) << setprecision(0) << i + j << setw(18)
<< setprecision(2) << fixed << fahren(centi) << ' ' << setw(15)
<< setprecision(2) << i + j << setw(18) << setprecision(2) << fixed << cent(i + j) << ' ' << endl;
}
return 0;
}
float cent(float f)
{
f = ((f * 9/5) + 32);
return f;
}void fahren( float &c)
{
c = ((c - 32) * 5/9);
}