0
#include <iostream>

using namespace std;

int main() { //Main Function

int w;
cout << "enter the weight of the watermelon: ";
cin >> w;

if (w <= 1 or w >= 100) {
cout << "error";
}

else {
if (w % 2 == 0) {
cout << "YES";
}
else {
cout << "NO";
}
}
return 0;

Compilation Errors:

 syntax error: missing ')' before identifier 'or'
 error C2065: 'or': undeclared identifier
 error C2146: syntax error: missing ';' before identifier 'w'
 error C2059: syntax error: ')'
 error C2059: syntax error: ';'
 error C2059: syntax error: 'else'
 error C2143: syntax error: missing ';' before '{'
 error C2447: '{': missing function header (old-style formal list?)
 error C2059: syntax error: 'return'
 error C2059: syntax error: '}'
 error C2143: syntax error: missing ';' before '}'
Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
Viktor
  • 11
  • 1
  • Where is the closing brace of `main`? Can't reproduce https://wandbox.org/permlink/uO8SyXIlymbJJZfU – Thomas Sablik May 23 '20 at 17:16
  • Remove the `return 0;`. The formatting of this makes it really difficult to match opening braces with their corresponding closing brace – WBuck May 23 '20 at 17:19
  • Did you copy-paste the code into the question, or rewrote it? Always copy-paste, otherwise you risk adding other unrelated errors, or worse *fix* the error you want to ask about. – Some programmer dude May 23 '20 at 17:19
  • Also, while indentation is not significant for the language, it do help to read and understand and follow the flow of the code for us humans reading it. Please learn to (consistently) indent your code. – Some programmer dude May 23 '20 at 17:20

1 Answers1

2

or in C++ is an "alternative token".

Your version of Visual Studio doesn't support these alternative tokens in your compilation mode.

Technically, that is in violation of the C++ standard.

However, it would anyway be more conventional to write ||, so just do that.

Asteroids With Wings
  • 17,071
  • 2
  • 21
  • 35