#include<iostream>
usingnamespace std;
int main()
{
double f,ccel,ffar,c;
f=0;
c=0;
char cel_or_far[30];
cout<<"Please specify if you want 'farenhiet' or 'celsius' : ";
cin>>cel_or_far;
if ( (stricmp ("Farenheit",cel_or_far)==0) || (stricmp ("farenheit",cel_or_far) ==0) );
{
cout<<"Please enter the value for Farenheit : ";
cin>>f;
ccel=(f-32)/1.8;
cout<<"Farenheit "<<f<<" is "<<ccel<<" in celsius "<<"\n";
}
elseif( (stricmp ("Celsius",cel_or_far)==0) || (stricmp ("clesius",cel_or_far) ==0) );
{
cout<<"Please enter the value for Celsius : ";
cin>>c;
ffar=(c*1.8)+32;
cout<<"Celsius "<<c<<" is "<<ffar<< "in celsius : "<<endl;
}
else
{
cout<<"You typed in "<<cel_or_far<<"\n\n";
}
system ("pause");
return 0;
}
Thanks in advance and an explaination would be helpful. ^^;
if (/*...*/ ) ; //←This is the problem
Your code structure
1 2 3 4 5 6 7
if(/*...*/)
; //THEN statement is closed here. else should be next statement
{/*...*/} //Not an else statement, but block statement,
//by language rules that means if statement does not have else and is closed here
else //...// Stray else which does not belong to any if, error