<pre>
<pre>#include<iostream.h>
#include<conio.h>
float Celsius(float,float ,float , float ,int);
float Kelvin(float C,float K,float F,float ans,int y); float Fahrenheit(float C,float K,float F,float ans,int y);
int main()
{
int x;
float answer;
cout<<"\t\t\tWElCOME TO TEMPERATURE CALCULATOR";
getch();
cout<<"\n\nSelect your first operator =>";
cout<<"\n1.Kelvin";
cout<<"\n2.Celsius";
cout<<"\n3.Fahrenheit\n\n";
cin>>x;
switch(x)
{
case 1:float Kelvin(float C,float K,float F,float ans,int y) ;
break;
case 2:float Celsius(float C,float K,float F, float ans,int y) ;
break;
case 3:float Fahrenheit(float C,float K,float F,float ans,int y) ;
break;
}
return 0 ;
} float Kelvin(float C,float K,float F, float ans,int y)
{
cout<<"\nSelect your second operator =>";
cout<<"\n1.Celsius";
cout<<"\n2.Fahrenheit";
cin>>y;
switch(y)
{case 1:cout<<"Enter Kelvin";
cin>>K;
C=K-273.15;
ans=C;
break;
case 2:cout<<"Enter Kelvin" ;
cin>>K;
F=K*9/5-459.67;
ans=F;
break;
}
cout<<"your answer is "<<ans;
return (0);
}
float Celsius(float C,float K,float F, float ans,int y)
{
cout<<"Select your second operator =>";
cout<<"\n1.Kelvin";
cout<<"\n2.Fahrenheit";
cin>>y;
switch(y)
{case 1:cout<<"Enter Celsius";
cin>>C;
K=C+273.15;
ans=K;
break;
case 2:cout<<"Enter Celsius" ;
cin>>C;
F=C*9/5+32;
ans=F;
break;
}
return ans;
}
float Fahrenheit(float C,float K,float F,float ans,int y)
{
cout<<"Select your second operator =>";
cout<<"\n1.Kelvin";
cout<<"\n2.Celsius";
cin>>y;
switch(y)
{case 1:cout<<"Enter Fahrenheit";
cin>>F;
K=(F+459.67)*5/9;
ans=K;
break;
case 2:cout<<"Enter Fahrenheit";
cin>>F;
C=(F-32)*5/9;
ans=C;
break;
}
return ans;
}
the error is in 21st 23rd and 25th line inside the switch
in the function calls
i am compiling using turboc++ 4.5
i will copypaste the errorsbelow:
error FUNC.CPP 21:Expression syntax in function main()
error FUNC.CPP 23:Expression syntax in function main()
error FUNC.CPP 25:Expression syntax in function main()
i am trying to make a temperature converter using functions and some switches
What I have tried:
//i have tried changing the function calls with almost everything ie parameters and the definition just everything buti didnot ask my teacher although i tried looking into the book but that doesnt help trying to do this for ovr a week but i cant pls help .can somebody repair the code that will be really helpful
thanks in advance