How to resolve the algorithm Integer comparison step by step in the Ol programming language

Published on 12 May 2024 09:40 PM
#Ol

How to resolve the algorithm Integer comparison step by step in the Ol programming language

Table of Contents

Problem Statement

Get two integers from the user. Then,   display a message if the first integer is: the second integer.

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

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Integer comparison step by step in the Ol programming language

Source code in the ol programming language

(define (compare a b)
  (cond ((< a b) "A is less than B")
        ((> a b) "A is greater than B")
        ((= a b) "A equals B")))

(print (compare 1 2))
; ==> A is less than B

(print (compare 2 2))
; ==> A equals B

(print (compare 3 2))
; ==> A is greater than B

; manual user input:
(print (compare (read) (read)))


  

You may also check:How to resolve the algorithm Delete a file step by step in the Emacs Lisp programming language
You may also check:How to resolve the algorithm AKS test for primes step by step in the Crystal programming language
You may also check:How to resolve the algorithm Sort three variables step by step in the Python programming language
You may also check:How to resolve the algorithm Hello world/Graphical step by step in the C programming language
You may also check:How to resolve the algorithm String matching step by step in the AWK programming language