0

Why is my code not compiling?

#include <iostream> using namespace std; float cels_fahr (float tc) { float tf; tf = 1.8 * tc + 32; return tf; } int main() { float cels; float fahr; cout << "Type temperature in Celsius:" << endl; cin << cels; fahr = cels_fahr (cels); cout << "Temperature in fahrenheit: " << fahr << endl; return 0; }

15th Oct 2016, 1:44 PM
Gabriele Donati
Gabriele Donati - avatar
4 Answers
+ 1
ohh. i see your problem. right after cout<<"type temperature......", there's a cin statement like this cin<<cels, it should be cin>>cels;
15th Oct 2016, 1:56 PM
Fhatuwani Luvhengo
Fhatuwani Luvhengo - avatar
+ 1
OMG! Such a stupid mistake! haha Working now. Thanks a lot! :D
15th Oct 2016, 2:00 PM
Gabriele Donati
Gabriele Donati - avatar
0
I tried that and it still won't compile.
15th Oct 2016, 1:53 PM
Gabriele Donati
Gabriele Donati - avatar
- 3
include a prototype before main, i.e float cels_fahr(float);
15th Oct 2016, 1:46 PM
Fhatuwani Luvhengo
Fhatuwani Luvhengo - avatar