function not returning correct result
hi im trying to solve a problem in a book im reading and i cant get the correct answer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
using namespace std;
float celsius(float);
int main (int argc, char * const argv[]) {
float fahrenheit;
for (fahrenheit=0; fahrenheit<21; fahrenheit++) {
cout<<celsius(fahrenheit) <<endl;
}
return 0;
}
float celsius(float fahrenheit){
return 5/9*(fahrenheit-32);
}
|
it keeps returning zero in each loop
Last edited on
try using this:
return 5.0/9.0*(fahrenheit-32.0);
hannes
Thanks! It worked!
Topic archived. No new replies allowed.