if vs else if?

I have 2 years experience of programmers. I have to ask you stupid a question about it... in my opinion i think its make no difference. correct me if i am wrong. please thanks.

this is the code from https://www.arduino.cc/en/Reference/Else

if (pinFiveInput < 500)
{
  // do Thing A
}
else if (pinFiveInput >= 1000)
{
  // do Thing B
}
else
{
  // do Thing C
}

if i have removed "else if" change to "if" would be like this...

if (pinFiveInput < 500)
{
  // do Thing A
}
if (pinFiveInput >= 1000)
{
  // do Thing B
}
else
{
  // do Thing C
}

Mm, it really make a difference.

For starters, the else is only checked against "pinFiveInput >= 1000" in the second case. So a pinFaveInput of 400 will trigger both Thing A and Thing C.

Also, the else if stucture saves the Arduino from even checking the "pinFiveInput >= 1000" if it already found "pinFiveInput < 500" was true. After finishing Thing A it will just exit.

And what if Thing A does something with pinFiveInput? Maybe sets it to 1200, do you want thing B to happen?

So if you just want one thing to happen, A, B or C, and the cases exclude each other you want to use if else. Because when you found a case that matched it's useless to check any further.

@ironheartbj18, yours is a question about logic rather than about programming. If you think about those three decisions oustide the context of a computer program I think you will see that there is a difference.

Think of these questions

is she hungry
   give her food
else is she thirsty
  give her drink
else
  do nothing

(By the way I don't mean that your question is inappropriate for the Forum)

...R