Arithmetic/Integer: Difference between revisions

m
Changed over to headers.
No edit summary
m (Changed over to headers.)
Line 3:
Get two integers from the user, and then output the sum, difference, product, integer quotient and remainder of those numbers. Don't include error handling.
 
==[[{{header|Ada]]}}==
[[Category:Ada]]
with Ada.Text_Io;
with Ada.Integer_Text_IO;
Line 22 ⟶ 21:
end Integer_Arithmetic;
 
==[[{{header|Befunge]]}}==
[[Category:Befunge]]
&&00p"=A",,:."=B ",,,00g.55+,v
v,+55.+g00:,,,,"A+B="<
Line 32 ⟶ 30:
 
 
==[[{{header|C]]}}==
[[Category:C]]
#include <stdio.h>
#include <stdlib.h>
Line 66 ⟶ 63:
}
 
==[[{{header|E]]}}==
[[Category:E]]
 
def arithmetic(a :int, b :int) {
Line 78 ⟶ 74:
}
 
==[[{{header|Forth]]}}==
[[Category:Forth]]
To keep the example simple, the word takes the two numbers from the stack. '''/mod''' returns two results; the stack effect is ( a b -- a%b a/b ).
: arithmetic ( a b -- )
Line 89 ⟶ 84:
cr ." a mod b = " . cr ;
 
==[[{{header|Haskell]]}}==
[[Category:Haskell]]
 
main = do
Line 105 ⟶ 99:
putStrLn $ "a / b = " ++ show (a `div` b)
 
==[[{{header|Java]]}}==
[[Category:Java]]
import java.util.Scanner;
Line 122 ⟶ 115:
}
 
==[[{{header|MAXScript]]}}==
[[Category:MAXScript]]
x = getKBValue prompt:"First number"
y = getKBValue prompt:"Second number:"
Line 134 ⟶ 126:
 
 
==[[{{header|Pascal]]}}==
[[Category:Pascal]]
program arithmetic(input, output)
Line 149 ⟶ 140:
end.
 
==[[{{header|Perl]]}}==
[[Category:Perl]]
 
my $a = <>;
Line 163 ⟶ 153:
;
 
==[[{{header|Pop11]]}}==
[[Category:Pop11]]
 
;;; Setup token reader
Line 178 ⟶ 167:
printf(a mod b, 'a mod b = %p\n');
 
==[[{{header|Python]]}}==
[[Category:Python]]
 
x = int(raw_input("Number 1: "))
Line 193 ⟶ 181:
raw_input( )
 
==[[{{header|Raven]]}}==
[[Category:Raven]]
 
' Number 1: ' print expect 0 prefer as x
Line 205 ⟶ 192:
x y % " remainder: %d\n" print
 
==[[{{header|Ruby]]}}==
[[Category:Ruby]]
 
puts 'Enter x and y'
Line 218 ⟶ 204:
"Remainder: #{x%y}"
 
==[[{{header|Scheme]]}}==
[[Category:Scheme]]
 
(define (arithmetic x y)
Line 245 ⟶ 230:
(lcm 8 12) => 24
 
==[[{{header|Tcl]]}}==
[[Category:Tcl]]
 
puts "Please enter two numbers:"
Line 270 ⟶ 254:
 
 
==[[{{header|Toka]]}}==
[[Category:Toka]]
 
[ ( a b -- )
Line 282 ⟶ 265:
 
 
==[[{{header|UNIX Shell]]}}==
[[Category:UNIX Shell]]
 
With external utilities:
Anonymous user