# Conversion of fahrenheit to celsius

Take the following as input.

Minimum Fahrenheit value
Maximum Fahrenheit value
Step

Print as output the Celsius conversions. Use the formula C = (5/9)(F – 32) E.g. for an input of 0, 100 and 20 the output is
0 17
20 6
40 4
60 15
80 26
100 37

My code is
#include
using namespace std;
int main()
{
int minf,maxf,step,f;
float c;
cout<<“enter the details of farenheit value”<<endl;
cin>>minf,maxf,step;
c=(f-32)*(5/9);
for(f=minf;f<=maxf;f=f+step)
{
cout<<f<<endl;
cout<<c<<endl;
}
return 0;

}
why it is not running?

Can u pls mention problem link.

Syntex problem

1. cout<<“enter the details of farenheit value”<<endl;
//NO NEED TO WRITE THIS LINE
2.cin>>minf,maxf,step;
cin>>minf>>maxf>>step <–Correct syntex
2. c=(f-32)*(5/9)
This will result 0 as (5/9) will converted to int that is 0 and then multiplied by (f-32)
you should write :
c=(((f-32)*5)/9);
3. Calculate c=(f-32)*(5/9) for every step in loop
4. For negative celcius value (non integer )
value=integer( c )+1 (seen inn sample output)
For positive calcius value (non integer value)
value=integer( c )

int main()
{
int minf,maxf,step,f;
float c;
cin>>minf>>maxf>>step;

for(f=minf;f<=maxf;f=f+step)
{
c=(((f-32)*5)/9);
if((c-int( c ))==0) // integer
{
cout<<f<<" “<<c<<endl;
}
else
{
if(c>0)
{
cout<<f<<” “<<int( c )<<endl;
}
else
{
cout<<f<<” "<<int( c )+1<<endl;
}

``````}
``````

}
return 0;

}

Hope u learned a lot from these mistakes. Hit like if u get the mistakes otherwise ping me again

1 Like
``````#include <iostream>
using namespace std;
int main()
{
int maxf,minf,step,tempc=0;
cin>>minf>>maxf>>step;
int tempf=minf;
while(tempf<=maxf){
tempc=(((tempf-32)*5)/9);
cout<<tempf<<" "<<tempc<<endl;
tempf=tempf+step;
}
return 0;
}``````