Sha256: 0de1dd4b98ee62c43119aa1ae7c500001aab119aec479a99eee4642bd6bdb722

Contents?: true

Size: 826 Bytes

Versions: 10

Compression:

Stored size: 826 Bytes

Contents

The Algol W integer division operator (called div) truncates towards zero.<br>
The result of the modulo operator (called rem) has the sign of the first operand when the operands have different signs.
begin
    integer a, b;
    write( "Enter 2 integers> " );
    read( a, b );
    write( "a  +  b: ", a  +  b ); % addition         %
    write( "a  -  b: ", a  -  b ); % subtraction      %
    write( "a  *  b: ", a  *  b ); % multiplication   %
    write( "a  /  b: ", a div b ); % integer division %
    write( "a mod b: ", a rem b ); % modulo           %
    % the ** operator returns a real result even with integer operands  %
    % ( the right-hand operand must always be an integer, the left-hand %
    % operand can be integer, real or complex )                         %
    write( "a  ^  b: ", round( a ** b ) )
end.

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/algol_w.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/algol_w.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/algol_w.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/algol_w.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/algol_w.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/algol_w.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/algol_w.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/algol_w.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/algol_w.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/algol_w.txt