Weird compiler error, no idea what's wrong

Something is wrong here which I
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Learning.cpp : main project file.

#include "stdafx.h"
#include <iostream>

void main()
{
	using namespace std;
	
	for(int x=0, y=1; x > y; x++)
	{
		char yn;
		cout << "Would you like to start?\n>";
		cin >> yn;
		yn = toupper(yn);
		switch(yn) {case 'Y': { y = (x-1); } default: { y = x+1; }}

	int number1, number2;
	cout << ">";
	cin >> number1;
	cout << endl;
	cout << "What number would you like to compare against\n>";
	cin >> number2; cout << endl;
	if number1>number2 { cout << number1 " is greater than " number2 << endl; }
	else if !(number1>number2) { cout << number1 " is not greater than " number2 << endl; }
	else if number1==number2 { cout << "The two numbers are equal" << endl; }


		cout << "Would you like to start?\n>";
		cin >> yn;
		yn = toupper(yn);
		switch(yn) {case 'Y': { y = (x-1); } default: { y = x+1; }}
	}
	system("PAUSE");
}


[small]1>------ Build started: Project: Learning, Configuration: Debug Win32 ------
1> Learning.cpp
1>Learning.cpp(24): error C2061: syntax error : identifier 'number1'
1>Learning.cpp(24): error C2143: syntax error : missing ';' before '{'
1>Learning.cpp(24): error C2143: syntax error : missing ';' before 'string'
1>Learning.cpp(24): error C2146: syntax error : missing ';' before identifier 'number2'
1>Learning.cpp(24): error C2563: mismatch in formal parameter list
1>Learning.cpp(24): error C2568: '<<' : unable to resolve function overload
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(1021): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=unsigned short,
1> _Traits=std::char_traits<unsigned short>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(1011): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(1003): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(977): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>Learning.cpp(25): error C2181: illegal else without matching if
1>Learning.cpp(25): error C2059: syntax error : '!'
1>Learning.cpp(25): error C2143: syntax error : missing ';' before '{'
1>Learning.cpp(25): error C2143: syntax error : missing ';' before 'string'
1>Learning.cpp(25): error C2146: syntax error : missing ';' before identifier 'number2'
1>Learning.cpp(25): error C2563: mismatch in formal parameter list
1>Learning.cpp(25): error C2568: '<<' : unable to resolve function overload
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(1021): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=unsigned short,
1> _Traits=std::char_traits<unsigned short>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(1011): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(1003): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream(977): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>Learning.cpp(26): error C2181: illegal else without matching if
1>Learning.cpp(26): error C2061: syntax error : identifier 'number1'
1>Learning.cpp(26): error C2143: syntax error : missing ';' before '{'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ===
[/small]

And sorry if system("PAUSE") annoys you, but that's the only thing my brain can memorise (even that I dont really understand)
You forgot to enclose the condition in parentheses.

if number1>number2

But in any case your code is invalid
Topic archived. No new replies allowed.