How to resolve the algorithm Arithmetic/Integer step by step in the XPL0 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Arithmetic/Integer step by step in the XPL0 programming language

Table of Contents

Problem Statement

Get two integers from the user,   and then (for those two integers), display their:

Don't include error handling. For quotient, indicate how it rounds   (e.g. towards zero, towards negative infinity, etc.). For remainder, indicate whether its sign matches the sign of the first operand or of the second operand, if they are different.

Bonus: Include an example of the integer divmod operator. For example: as in #Haskell, #Python and #ALGOL 68

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Arithmetic/Integer step by step in the XPL0 programming language

Source code in the xpl0 programming language

include c:\cxpl\codes;
int A, B;
[A:= IntIn(0);
 B:= IntIn(0);
IntOut(0, A+B); CrLf(0);
IntOut(0, A-B); CrLf(0);
IntOut(0, A*B); CrLf(0);
IntOut(0, A/B); CrLf(0);        \truncates toward zero
IntOut(0, rem(0)); CrLf(0);     \remainder's sign matches first operand (A)
]

  

You may also check:How to resolve the algorithm Read a specific line from a file step by step in the Action! programming language
You may also check:How to resolve the algorithm Rot-13 step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Plot coordinate pairs step by step in the Go programming language
You may also check:How to resolve the algorithm String concatenation step by step in the Sather programming language
You may also check:How to resolve the algorithm Substring/Top and tail step by step in the Nemerle programming language