lundi 1 juin 2020

`if ((letter >= 'P') && (letter <= 'S'))` ... why does this if statement work?

Came across this statement in a C book, if ((letter >= 'P') && (letter <= 'S'))

It's trying to check if the letter falls between P and S (including both) and I was quite surprised to see it work.

  1. How is it possible to do greater-than/lesser-than type operations on alphabets (character data type)?
  2. It is a feature in only C or in other programming languages as well?

Aucun commentaire:

Enregistrer un commentaire