extremely simple problem

i apologise for asking such a stupid question, i am extremely new and this problem has been bugging me for a while.
i have this very simple little fahrenheit to celsius conversion program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;
double converter(double f)
{
    return (f - 32)/1.8;
}
int main()
{
    double fahrenheit;
    cout << "insert fahrenheit: ";
    cin >> fahrenheit;
if (fahrenheit <= '-459.40')
    cout << "you are a retard.";
else
    double celsius = converter(fahrenheit);
    cout << fahrenheit << " fahrenheit equals " << celsius << " celsius." <<endl;
    return 0;
}

what i want it to do is: if you try to input a value less than or equal to -459.4, it gives you a message saying you are a retard.
the program works fine without the if else statement, but when i use the if else statement it gives me an error saying 'celsius was not declared in this scope'.
could you please tell me the source of the problem and how i can fix this.

tl;dr: stuff's not working pls fix.
fahrenheit <= '-459.40'
This is a weird attempt to compare a variable with a mutant character.

fahrenheit <= -459.40
This is comparing a variable to the number -459.40


Your else block contains a single statement only; this one.
double celsius = converter(fahrenheit);

If you want more to be in the else block, use braces, like this.

1
2
3
4
5
6
else
{
    double celsius = converter(fahrenheit);
    cout << fahrenheit << " fahrenheit equals " << celsius << " celsius."  << endl;
}
return 0;
Last edited on
thank you very much!
reducing
aspie
posts
for ed

ignore the above.
Last edited on
Topic archived. No new replies allowed.