
Basic Data Operation

This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:


Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |
Comparison |
Matching
Memory Operations
Pointers & references |
Addresses


Get two integers from the user.

Then,   display a message if the first integer is:

   less than, 
   equal to,   or 
   greater than
the second integer.



Test the condition   for each case separately,   so that   all three comparison operators are used   in the code.



Related task

   String comparison


ask question "Enter 2 numbers (comma separated)" with empty titled "Enter 2 numbers"
if it is not empty then
    put item 1 of it into num1
    put item 2 of it into num2
    if isnumber(num1) and isnumber(num2) then
        if num1 < num2 then answer num1 && "is less than" && num2
        if num1 is num2 then answer num1 && "is equal to" && num2
        if num1 > num2 then answer num1 && "is greater than" && num2
 
        -- alternative is to use switch case construct
        switch
            case (num1 < num2)
                answer num1 && "is less! than" && num2; break
            case (num1 > num2) 
                answer num1 && "is greater! than" && num2; break
            case (num1 = num2)
                answer num1 && "equal! to" && num2
        end switch
    end if
end if