error C2143: syntax error

Hi all,

I am learning C++ from 0.
I have a very simple code:

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
int numb1;
int numb2;

cout << "Enter the two integers and I will tell you:\n";
cin >> numb1 >> numb2;
if numb1==numb2
cout << numb1 << " is equal to " << numb2 << endl;
if numb1!=numb2
cout << numb1 << " is not equal to " << numb2 << endl;
if numb1>numb2
cout << numb1 << " is greater than " << numb2 << endl;
if numb1<numb2
cout << numb1 << " is less than " << numb2 << endl;
if numb1=>numb2
cout << numb1 << " is greater than or equal to " << numb2 << endl;
if numb1=<numb2
cout << numb1 << " is less than or equal to " << numb2 << endl;

system("PAUSE");
return 0;
}

When I compile, I get these errors:


1>c:\documents and settings\administrateur\bureau\howtoprograminc++\fig01_14\fig01_14\fig01_14.cpp(13) : error C2061: syntax error : identifier 'numb1'
1>c:\documents and settings\administrateur\bureau\howtoprograminc++\fig01_14\fig01_14\fig01_14.cpp(15) : error C2061: syntax error : identifier 'numb1'
1>c:\documents and settings\administrateur\bureau\howtoprograminc++\fig01_14\fig01_14\fig01_14.cpp(17) : error C2061: syntax error : identifier 'numb1'
1>c:\documents and settings\administrateur\bureau\howtoprograminc++\fig01_14\fig01_14\fig01_14.cpp(19) : error C2061: syntax error : identifier 'numb1'
1>c:\documents and settings\administrateur\bureau\howtoprograminc++\fig01_14\fig01_14\fig01_14.cpp(21) : error C2061: syntax error : identifier 'numb1'
1>c:\documents and settings\administrateur\bureau\howtoprograminc++\fig01_14\fig01_14\fig01_14.cpp(23) : error C2061: syntax error : identifier 'numb1'


Thank your for your response.

Best regards,
Last edited on
You must to enclose the if condition in parentheses, like this:
1
2
	if (numb1==numb2)
		cout << numb1 << " is equal to " << numb2 << endl;
Thank you Peter87 so much, I had another error also:
>= i instead of =>

It is OK now
Last edited on
Topic archived. No new replies allowed.