Jump to content

Integer comparison: Difference between revisions

Line 30:
 
=={{header|ALGOL 68}}==
{{works with|ALGOL 68|Standard - no extensions to language used}}
main: (
Note: the standard includes the characters "≤", "≥" and "≠". These appear
INT a, b;
in the character sets [[wp:ALCOL]], [[wp:GOST 10859]], [http://www.w3.org/TR/REC-MathML/chap6/ISOTECH1.html ISOtech] and
readf(($g" "gl$, a, b));
IBM's [[:wp:EBCDIC]] code pages e.g. [http://www-01.ibm.com/software/globalization/cs/cs01340.jsp code page 1340].
 
IF a < b THEN
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
printf(($g" is less than "gl$, a, b))
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}}
ELIF a = b THEN
The current distribution of both [[ALGOL 68G]] and [[ELLA ALGOL 68]] compilers only
printf(($g" is equal to "gl$, a, b))
allow [[wp:ASCII]] characters (ASCII has neither "&le;", "&ge;" nor "&ne;" characters).
ELIF a > b THEN
<pre>main: (
printf(($g" is greater than "gl$, a, b))
INT FIa, b;
read((a, space, b, new line));
)
 
IF a <= b OR a LE b # OR a &le; b # THEN
print((a," is less or equal to ", b, new line))
FI;
IF a < b OR a LT b THEN
printfprint(($ga," is less than "gl$, ab, bnew line))
ELIF a = b OR a EQ b THEN
printfprint(($ga," is equal to "gl$, ab, bnew line))
ELIF a > b OR a GT b THEN
printfprint(($ga," is greater than "gl$, ab, bnew line))
FI;
IF a /= b OR a NE b # OR a &ne; b # THEN
print((a," is not equal to ", b, new line))
FI;
IF a >= b OR a GE b # OR a &ge; b # THEN
print((a," is greater or equal to ", b, new line))
FI
)</pre>
Example output:
<pre>
3 4
+3 is less or equal to +4
+3 is less than +4
+3 is not equal to +4
</pre>
 
=={{header|AWK}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.