console application in c++ have error with that code it says illigle else without matching if please check and post the correct code
note: it is a tempreture convertor
// convertor.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int c,t;
cout<<"please write c to convert from (c-f) or f to convert from(f-c)";
cin>>c;
if(c=='c')
cout<<"pls enter the tempreture in celcius";
cin>>t;
cout<<5/9+(t-32);
else if(c=='f')
cout<<"pls enter the tempreture in fahrenheit";
cin>>t;
cout<<9/5+t+32;
return 0;
}
I have corrected some of the syntax errors. It is important to use the correct types. So I have made your variable c a char because it expects to be set to a character, either 'c' or 'f'.
Your variable t I have made a float because that stores decimal numbers of the form 98.4
Your formulae are still wrong, you need to research those.
Your statement after the if and else if clauses need to be in braces {}.
#include <iostream>
usingnamespace std;
int main(int argc, char* argv[]) // This is the correct signature for the main function
{
char c; // this is a character 'c' or 'f'
float t; // this has a decimal point
cout<<"please write c to convert from (c-f) or f to convert from(f-c)";
cin>>c;
if(c=='c')
{ // You need to put braces round the next few instructions
cout<<"pls enter the tempreture in celcius";
cin>>t;
cout<<5/9+(t-32); //this is wrong
}
elseif(c=='f')
{ // Here too you need braces
cout<<"pls enter the tempreture in fahrenheit";
cin>>t;
cout<<9/5+t+32; // this is wrong
}
return 0;
}