Page 1 of 1

Parse Error causing trouble

Posted: Sun Sep 28, 2003 9:29 pm
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!!

Posted: Sun Sep 28, 2003 9:34 pm
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?

Posted: Sun Sep 28, 2003 9:51 pm
by JAM
Might explain the parse error running that as a .php on a server...

Posted: Mon Sep 29, 2003 12:36 am
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;