Arithmetic/Integer: Difference between revisions

Content added Content deleted
No edit summary
m (Changed over to headers.)
Line 3: 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.
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.


==[[Ada]]==
=={{header|Ada}}==
[[Category:Ada]]
with Ada.Text_Io;
with Ada.Text_Io;
with Ada.Integer_Text_IO;
with Ada.Integer_Text_IO;
Line 22: Line 21:
end Integer_Arithmetic;
end Integer_Arithmetic;


==[[Befunge]]==
=={{header|Befunge}}==
[[Category:Befunge]]
&&00p"=A",,:."=B ",,,00g.55+,v
&&00p"=A",,:."=B ",,,00g.55+,v
v,+55.+g00:,,,,"A+B="<
v,+55.+g00:,,,,"A+B="<
Line 32: Line 30:




==[[C]]==
=={{header|C}}==
[[Category:C]]
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
Line 66: Line 63:
}
}


==[[E]]==
=={{header|E}}==
[[Category:E]]


def arithmetic(a :int, b :int) {
def arithmetic(a :int, b :int) {
Line 78: Line 74:
}
}


==[[Forth]]==
=={{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 ).
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 -- )
: arithmetic ( a b -- )
Line 89: Line 84:
cr ." a mod b = " . cr ;
cr ." a mod b = " . cr ;


==[[Haskell]]==
=={{header|Haskell}}==
[[Category:Haskell]]


main = do
main = do
Line 105: Line 99:
putStrLn $ "a / b = " ++ show (a `div` b)
putStrLn $ "a / b = " ++ show (a `div` b)


==[[Java]]==
=={{header|Java}}==
[[Category:Java]]
import java.util.Scanner;
import java.util.Scanner;
Line 122: Line 115:
}
}


==[[MAXScript]]==
=={{header|MAXScript}}==
[[Category:MAXScript]]
x = getKBValue prompt:"First number"
x = getKBValue prompt:"First number"
y = getKBValue prompt:"Second number:"
y = getKBValue prompt:"Second number:"
Line 134: Line 126:




==[[Pascal]]==
=={{header|Pascal}}==
[[Category:Pascal]]
program arithmetic(input, output)
program arithmetic(input, output)
Line 149: Line 140:
end.
end.


==[[Perl]]==
=={{header|Perl}}==
[[Category:Perl]]


my $a = <>;
my $a = <>;
Line 163: Line 153:
;
;


==[[Pop11]]==
=={{header|Pop11}}==
[[Category:Pop11]]


;;; Setup token reader
;;; Setup token reader
Line 178: Line 167:
printf(a mod b, 'a mod b = %p\n');
printf(a mod b, 'a mod b = %p\n');


==[[Python]]==
=={{header|Python}}==
[[Category:Python]]


x = int(raw_input("Number 1: "))
x = int(raw_input("Number 1: "))
Line 193: Line 181:
raw_input( )
raw_input( )


==[[Raven]]==
=={{header|Raven}}==
[[Category:Raven]]


' Number 1: ' print expect 0 prefer as x
' Number 1: ' print expect 0 prefer as x
Line 205: Line 192:
x y % " remainder: %d\n" print
x y % " remainder: %d\n" print


==[[Ruby]]==
=={{header|Ruby}}==
[[Category:Ruby]]


puts 'Enter x and y'
puts 'Enter x and y'
Line 218: Line 204:
"Remainder: #{x%y}"
"Remainder: #{x%y}"


==[[Scheme]]==
=={{header|Scheme}}==
[[Category:Scheme]]


(define (arithmetic x y)
(define (arithmetic x y)
Line 245: Line 230:
(lcm 8 12) => 24
(lcm 8 12) => 24


==[[Tcl]]==
=={{header|Tcl}}==
[[Category:Tcl]]


puts "Please enter two numbers:"
puts "Please enter two numbers:"
Line 270: Line 254:




==[[Toka]]==
=={{header|Toka}}==
[[Category:Toka]]


[ ( a b -- )
[ ( a b -- )
Line 282: Line 265:




==[[UNIX Shell]]==
=={{header|UNIX Shell}}==
[[Category:UNIX Shell]]


With external utilities:
With external utilities: