Search code examples
integernumberspascalfreepascalmodulo

How to detect if an integer is two-digit or not in pascal. (no functions


How can I use mod, or div, to detect if a given positive integer is a two-tigit one? For instance, if the given number is 23 it will shows a message saying 'Two-digit number' But if the number is 230 it will show 'Not a two-digit number' NOTE: I HAVE TO USE ONLY SIMPLE COMMANDS - NO FUNCTIONS

Let's say the given number is 77 I tried doing 77 mod 10 But it didn't work for all the number What should I do?


Solution

  • Using just div:

    if ((x div 100) < 1) and ((x div 10) >= 1) then
      ...