This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -1,3 +1,3 @@
{{basic data operation}}Get two integers from the user, and then output if the first one is less, equal or greater than the other. Test the condition ''for each case separately'', so that ''all three comparison operators are used'' in the code.
{{basic data operation}}Get two integers from the user, and then output if the first one is less than, equal to, or greater than the other. Test the condition ''for each case separately'', so that ''all three comparison operators are used'' in the code.
See also:[[String comparison]]

View file

@ -0,0 +1,26 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Int-Compare.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(10).
01 B PIC 9(10).
PROCEDURE DIVISION.
DISPLAY "First number: " WITH NO ADVANCING
ACCEPT A
DISPLAY "Second number: " WITH NO ADVANCING
ACCEPT B
* *> Note: Longer verbal forms may be used instead of symbols
* *> e.g. 'IS GREATER THAN' instead '<'
IF A < B
DISPLAY A " is less than " B
ELSE IF A = B
DISPLAY A " is equal to " B
ELSE IF A > B
DISPLAY A " is larger than " B
END-IF
GOBACK
.

View file

@ -1,5 +1,5 @@
my Int $a = floor $*IN.get;
my Int $b = floor $*IN.get;
my $a = prompt("1st int: ").floor;
my $b = prompt("2nd int: ").floor;
if $a < $b {
say 'Less';

View file

@ -1 +1 @@
say <Less Equal Greater>[($a cmp $b) + 1];
say <Less Equal Greater>[($a <=> $b) + 1];

View file

@ -0,0 +1 @@
say prompt("1st int: ") <=> prompt("2nd int: ");

View file

@ -18,7 +18,7 @@ getInt: procedure /*prompt the CBLF, get an integer*/
when words(x)>1 then call serr 'Too many arguments entered.'
when \datatype(x,'N') then call serr "Argument isn't numeric:" x
when \datatype(x,'W') then call serr "Argument isn't an integer:" x
otherwise return x /*Eureka! Return X to invoker.*/
otherwise return x /*Eureka! Return X to invoker.*/
end /*select*/
end /*forever*/
/*──────────────────────────────────SERR subroutine─────────────────────*/