How to resolve the algorithm Sort three variables step by step in the IS-BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sort three variables step by step in the IS-BASIC programming language

Table of Contents

Problem Statement

Sort   (the values of)   three variables   (X,   Y,   and   Z)   that contain any value   (numbers and/or literals). If that isn't possible in your language, then just sort numbers   (and note if they can be floating point, integer, or other). I.E.:   (for the three variables   x,   y,   and   z),   where: After sorting, the three variables would hold: For numeric value sorting, use: I.E.:   (for the three variables   x,   y,   and   z),   where: After sorting, the three variables would hold: The variables should contain some form of a number, but specify if the algorithm used can be for floating point or integers.   Note any limitations. The values may or may not be unique. The method used for sorting can be any algorithm;   the goal is to use the most idiomatic in the computer programming language used. More than one algorithm could be shown if one isn't clearly the better choice.

One algorithm could be:

Another algorithm   (only for numeric values):

Show the results of the sort here on this page using at least the values of those shown above.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Sort three variables step by step in the IS-BASIC programming language

Source code in the is-basic programming language

100 LET X=77444:LET Y=-12:LET Z=0
110 PRINT X;Y;Z
120 CALL SHORT(X,Y,Z)
130 PRINT X;Y;Z
140 DEF SHORT(REF A,REF B,REF C)
150   IF A>B THEN LET T=A:LET A=B:LET B=T
160   IF B>C THEN LET T=B:LET B=C:LET C=T
170   IF A>B THEN LET T=A:LET A=B:LET B=T
180 END DEF

  

You may also check:How to resolve the algorithm Execute a system command step by step in the Raku programming language
You may also check:How to resolve the algorithm Start from a main routine step by step in the Racket programming language
You may also check:How to resolve the algorithm JSON step by step in the Groovy programming language
You may also check:How to resolve the algorithm Boolean values step by step in the Ursa programming language
You may also check:How to resolve the algorithm Word wrap step by step in the C++ programming language