|
|
In function 'char scale()': 29:1: warning: no return statement in function returning non-void [-Wreturn-type] In function 'void celcius(float, float, char)': 42:20: warning: parameter 'finalC' set but not used [-Wunused-but-set-parameter] In function 'void fahrenheit(float, float, char)': 52:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses] 50:23: warning: parameter 'finalF' set but not used [-Wunused-but-set-parameter] In function 'int main()': 74:18: error: no matching function for call to 'fahrenheit(char&)' 74:18: note: candidates are: 10:6: note: void fahrenheit(char, float, float) 10:6: note: candidate expects 3 arguments, 1 provided 50:6: note: void fahrenheit(float, float, char) 50:6: note: candidate expects 3 arguments, 1 provided 75:23: error: no matching function for call to 'celcius(char&, float&)' 75:23: note: candidates are: 9:6: note: void celcius(char, float, float) 9:6: note: candidate expects 3 arguments, 2 provided 42:6: note: void celcius(float, float, char) 42:6: note: candidate expects 3 arguments, 2 provided |
|
|
double
rather than float, the precision of float is easily exceeded, that's why double is the default. I also made some of the parameters const
, this means the compiler can enforce the idea that we are not going to change those values inside the function.==
for comparison in a conditional, =
is for assignment in an expression.
|
|
#include <iostream> using namespace std; // Function prototypes void Welcome(); char scale(); float temperature(); void celcius (char, float, float); void fahrenheit(char, float, float); void answer(float, float); // Display welcome message void Welcome() { cout<< "This program performs Celcius/Fahrenheit conversions" << endl; } // Ask for initial temperature scale char scale() { cout << "What's the initial temperature scale(F or C)?: "; cin >> Temp; /*if ((Temp != 'F') || (Temp != 'C')) cout<< "ERROR" <<endl;*/ } // Ask for initial temperature in degrees float temperature() { float Num; cout << "What is the temperature in degrees (enter numbers only)?: "; cin >> Num; } // Convert from Fahrenheit to Celcius void celcius(float finalC&, const float Num, const char Temp) { if (Temp == 'F') finalC = (Num - 32)/(1.8); } // Convert from Celcius to Fahrenheit void fahrenheit(float finalF&, const float Num, const char Temp) { if (Temp == 'C') finalF = (1.8 * Num) + 32; } // Display final output message void answer(float finalF, float finalC) { cout << "Your temperature reading converts as follows:" << endl << endl; cout << "Fahrenheit: " << finalF << endl; cout << "Celcius: " << finalC << endl; } // Main function executes other functions int main() { char Temp; float Num, finalF, finalC; Welcome(); Temp = scale(); Num = temperature(); fahrenheit(Temp); celcius(Temp, finalC); answer(finalF, finalC);*/ return 0; } |
<>
button on the format menu.What exactly do you mean when you say the function call doesn't match the function definition? |
... , you must have the same number of arguments with the correct types. |
fahrenheit(Temp);
void fahrenheit(char, float, float);
|
|