+ 1

Whts wrong in this code for conversion of farenheit temp into celsius temp

#include <iostream> using namespace std; int main() { int c=0,f=0; c=(f-32) *5/9; cout<<"enter temp. in f"<<endl; cin>>f; cout<<"temp in celsius is"<<c<<endl; return 0; }

18th Dec 2016, 4:01 PM
nikhil vasaikar
nikhil vasaikar - avatar
1 Answer
+ 1
the line in which value of c is calculated must be placed after the input of f. also use float instead of int. corrected code: #include <iostream> using namespace std; int main() { float c=0,f=0; cout<<"enter temp. in f"<<endl; cin>>f; c=(f-32) *5/9; cout<<"temp in celsius is"<<c<<endl; return 0; }
18th Dec 2016, 4:12 PM
Ravi Kumar
Ravi Kumar - avatar