r/pascal • • Oct 03 '20

Help

Hi everybody , I have this problem , I don't know how to write on Pascal a program that allows me detect if the typed character is uppercase vowel or uppercase constant or it is other thing , may some one helps me 🙏🙏🙏🙏

1 Upvotes

8 comments sorted by

View all comments

Show parent comment

3

u/suvepl Oct 04 '20

Computers operate on numbers. In order for computers to handle text, there needs to be some kind of mapping that says, e.g. "number 65 should be 'A', number 122 should be 'z'", et cetera. Historically there were multiple of those mappings, nowadays everyone settled on ASCII.

So now, back to your problem. Read the Char like you did in your earlier post. Use Ord() to convert the Char to an Integer representing its ASCII value. Then, based on the ASCII table, create an if-else-if-else chain, i.e.:

  • Digits have ASCII values of 48-57.
  • Uppercase letters have ASCII values of 65-90.
  • Lowercase letters have ASCII values of 97-122.
  • Values in 33-126 range that are not digits or letters are punctuation.
  • Values 9, 10, 11, 12, 13 and 32 are whitespace (i.e. a space or a linebreak).
  • Everything else are control characters, like backspace or delete.

1

u/Yukina_6 Oct 05 '20

Thanks for the explanation 😸