
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


<cffunction name="CompareInteger">
    <cfargument name="Integer1" type="numeric">
    <cfargument name="Integer2" type="numeric">
    <cfset VARIABLES.Result = "" >
    <cfif ARGUMENTS.Integer1 LT ARGUMENTS.Integer2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is less than " & ARGUMENTS.Integer2 & ")" >
    </cfif>
    <cfif ARGUMENTS.Integer1 LTE ARGUMENTS.Integer2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is less than or equal to " & ARGUMENTS.Integer2 & ")" >
    </cfif>
    <cfif ARGUMENTS.Integer1 GT ARGUMENTS.Integer2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is greater than " & ARGUMENTS.Integer2 & ")" >
    </cfif>
    <cfif ARGUMENTS.Integer1 GTE ARGUMENTS.Integer2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is greater than or equal to " & ARGUMENTS.Integer2 & ")" >
    </cfif>
    <cfif ARGUMENTS.Integer1 EQ ARGUMENTS.Integer2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is equal to " & ARGUMENTS.Integer2 & ")" >
    </cfif>
    <cfif ARGUMENTS.Integer1 NEQ ARGUMENTS.Integer2 >
	    <cfset VARIABLES.Result = VARIABLES.Result & "(" & ARGUMENTS.Integer1 & " is not equal to " & ARGUMENTS.Integer2 & ")" >
    </cfif>
    <cfreturn VARIABLES.Result >
</cffunction>