How to resolve the algorithm Even or odd step by step in the Oberon-2 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Even or odd step by step in the Oberon-2 programming language
Table of Contents
Problem Statement
Test whether an integer is even or odd. There is more than one way to solve this task:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Even or odd step by step in the Oberon-2 programming language
Source code in the oberon-2 programming language
MODULE EvenOrOdd;
IMPORT
S := SYSTEM,
Out;
VAR
x: INTEGER;
s: SET;
BEGIN
x := 10;Out.Int(x,0);
IF ODD(x) THEN Out.String(" odd") ELSE Out.String(" even") END;
Out.Ln;
x := 11;s := S.VAL(SET,LONG(x));Out.Int(x,0);
IF 0 IN s THEN Out.String(" odd") ELSE Out.String(" even") END;
Out.Ln;
x := 12;Out.Int(x,0);
IF x MOD 2 # 0 THEN Out.String(" odd") ELSE Out.String(" even") END;
Out.Ln
END EvenOrOdd.
You may also check:How to resolve the algorithm Create a file step by step in the S-BASIC programming language
You may also check:How to resolve the algorithm Emirp primes step by step in the Pascal programming language
You may also check:How to resolve the algorithm Forward difference step by step in the Plain English programming language
You may also check:How to resolve the algorithm Metaprogramming step by step in the TXR programming language
You may also check:How to resolve the algorithm Dot product step by step in the Elixir programming language