Parse Error causing trouble

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
default720
Forum Newbie
Posts: 1
Joined: Sun Sep 28, 2003 9:29 pm

Parse Error causing trouble

Post by default720 »

Hi.. for some reason im getting a parse error for this section:

#include <iostream>
using namespace std;
int main()

{
const int MAXIMUM = 30;//people
int num_people;

cout << "Enter the amount of people attending the meeting: ";
cin >> num_people;

{
cout << "The meeting cannot be held as planned due to fire regulations.\n";
cout << "Please exclude" << (num_people > MAXIMUM) << "people.\n";
}
else
{
cout << "It is legal to hold the meeting.\n";
cout << "An additional" << (MAXIMUM - num_people) << "people may attend the meeting.\n";
}

return 0;
}

im getting the errors before 'else' and 'return' aslso it is saying something is wrong with 'int main()'

PLEASE HELP!!
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

that's not PHP right? i have NEVER EVER seen such a code like that in PHP, is that C or Python or something else?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Might explain the parse error running that as a .php on a server...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

moved to Miscellaneous since this is a c++ related topic.

The compiler is right, there's no if for the else-statement
Probably a copy&paste-error. The code (somehow) makes sense as

Code: Select all

#include <iostream>
using namespace std;
int main()
&#123;
	const int MAXIMUM = 30;//people
	int num_people;

	cout << "Enter the amount of people attending the meeting: ";
	cin >> num_people;

	if (num_people > MAXIMUM)
	&#123;
		cout << "The meeting cannot be held as planned due to fire regulations.\n";
		cout << "Please exclude " << (num_people - MAXIMUM) << " people.\n";
	&#125;
	else
	&#123;
		cout << "It is legal to hold the meeting.\n";
		cout << "An additional " << (MAXIMUM - num_people) << " people may attend the meeting.\n";
	&#125;

	return 0;
&#125;
Post Reply