How to resolve the algorithm Angle difference between two bearings step by step in the XPL0 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Angle difference between two bearings step by step in the XPL0 programming language

Table of Contents

Problem Statement

Finding the angle between two bearings is often confusing.[1]

Find the angle which is the result of the subtraction b2 - b1, where b1 and b2 are the bearings. Input bearings are expressed in the range   -180   to   +180   degrees. The  result  is also expressed in the range   -180   to   +180   degrees.

Compute the angle for the following pairs:

Allow the input bearings to be any (finite) value.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Angle difference between two bearings step by step in the XPL0 programming language

Source code in the xpl0 programming language

real    B1, B2, Ang;
[Text(0, "   Bearing 1       Bearing 2      Difference");
loop   [B1:= RlIn(1);
        B2:= RlIn(1);
        Ang:= B2 - B1;
        while Ang >  180. do Ang:= Ang - 360.;
        while Ang < -180. do Ang:= Ang + 360.;
        CrLf(0);
        RlOut(0, B1);  ChOut(0, 9);
        RlOut(0, B2);  ChOut(0, 9);
        RlOut(0, Ang);
       ];
]

  

You may also check:How to resolve the algorithm Letter frequency step by step in the Haskell programming language
You may also check:How to resolve the algorithm String length step by step in the OCaml programming language
You may also check:How to resolve the algorithm Currency step by step in the Perl programming language
You may also check:How to resolve the algorithm Sleeping Beauty problem step by step in the Pascal programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the WDTE programming language