I have ABSOLUTELY NO IDEA why syntax error

Anyone see mistake ?

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
  #include<iostream>
using namespace std;
int main()
{
	int month, day, year;
	cout<<"Please enter a month";
	cin>>month;
	if(month>0 && month<=12)
	{	
		cout<<"Please enter a day";
		cin>>day;
		if(day>0 && day<=31)
		{
			cout<<"Please enter a year";
			cin>>year;
			if(year>0 && year<=99)
			{	
				cout<<"Thank you for valid input";
				if(day*month==year)
					cout<<"This date is Magic!";
				else
			}		cout<<"This date is not magic";	
			else
		}		cout<<"Please enter a valid year";
		else
			cout<<"Please enter a valid day";
	}
	else
		cout<<"Please enter a valid month";
	return 0;
}
line 22: } immediately follows the else from line 21

same problem on line 24
Last edited on
With a bit of rigorous restructuring (as in, did nothing but added line breaks and tabs):

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
#include<iostream>
using namespace std;
int main()
{
	int month, day, year;
	cout<<"Please enter a month";
	cin>>month;
	if(month>0 && month<=12)
	{	
		cout<<"Please enter a day";
		cin>>day;
		if(day>0 && day<=31)
		{
			cout<<"Please enter a year";
			cin>>year;
			if(year>0 && year<=99)
			{	
				cout<<"Thank you for valid input";
				if(day*month==year)
					cout<<"This date is Magic!";
				else
			}		
			cout<<"This date is not magic";	
			else
		}		
		cout<<"Please enter a valid year";
		else
			cout<<"Please enter a valid day";
	}
	else
		cout<<"Please enter a valid month";
	return 0;
}


Errors should be hard to miss now.
Last edited on
Topic archived. No new replies allowed.