I am trying to make a new original program and something weird keeps happening
this is the code I made
int a = 37;
void setup() {
// put your setup code here, to run once
if (a < 20) {
Serial.println("A is less than 20");
}
if else (a < 30); {
Serial.println("A is less than thirty but greater than twenty");
}
if else (a < 40); {
Serial.println("A is less than forty but greater than thirty");
}
if else (a < 50); {
Serial.println("A is less than fifty but greater than forty");
}
else (a > 50); {
Serial.println("A is greater than fifty");
}
}
void loop() {
// put your main code here, to run repeatedly:
}
And this is the error code I got
Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Users\rafor\Documents\Arduino\Number_calculator\Number_calculator.ino: In function 'void setup()':
Number_calculator:10:6: error: expected '(' before 'else'
if else (a < 30); {
^~~~
Number_calculator:13:6: error: expected '(' before 'else'
if else (a < 40); {
^~~~
Number_calculator:16:6: error: expected '(' before 'else'
if else (a < 50); {
^~~~
Number_calculator:19:3: error: 'else' without a previous 'if'
else (a > 50); {
^~~~
exit status 1
expected '(' before 'else'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Could anybody help me?