Jump to content

Integer comparison: Difference between revisions

m
Spelling/grammar/aesthetics.
m (→‎{{header|J}}: Improved grammar in commentary.)
m (Spelling/grammar/aesthetics.)
Line 1:
{{task}}{{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.
{{task}}
{{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.
 
=={{header|Ada}}==
Line 75 ⟶ 73:
(t (format t "Cannot determine relevance between ~A and ~B!" a b)))))
 
After hitting enter, the REPL is expecting the two numbers right away. You can enter the two numbers, and the result will print immediately. Alternatively, you can wrap this code in a function definition:
 
(defun compare-integers ()
Line 290 ⟶ 288:
'''Interpreter:''' [[Perl]] 5.x
 
SeperateSeparate tests for less than, greater than, and equals
 
sub test_num {
Line 306 ⟶ 304:
};
 
All three tests in one. ifIf $f is less than $s return -1, greater than return 1, equal to return 0
 
sub test_num {
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.