How to resolve the algorithm Logical operations step by step in the COBOL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Logical operations step by step in the COBOL programming language
Table of Contents
Problem Statement
Write a function that takes two logical (boolean) values, and outputs the result of "and" and "or" on both arguments as well as "not" on the first arguments. If the programming language doesn't provide a separate type for logical values, use the type most commonly used for that purpose. If the language supports additional logical operations on booleans such as XOR, list them as well.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Logical operations step by step in the COBOL programming language
Source code in the cobol programming language
IDENTIFICATION DIVISION.
PROGRAM-ID. print-logic.
DATA DIVISION.
LOCAL-STORAGE SECTION.
01 result PIC 1 USAGE BIT.
LINKAGE SECTION.
01 a PIC 1 USAGE BIT.
01 b PIC 1 USAGE BIT.
PROCEDURE DIVISION USING a, b.
COMPUTE result = a B-AND b
DISPLAY "a and b is " result
COMPUTE result = a B-OR b
DISPLAY "a or b is " result
COMPUTE result = B-NOT a
DISPLAY "Not a is " result
COMPUTE result = a B-XOR b
DISPLAY "a exclusive-or b is " result
GOBACK
.
You may also check:How to resolve the algorithm Department numbers step by step in the Go programming language
You may also check:How to resolve the algorithm Window creation step by step in the Go programming language
You may also check:How to resolve the algorithm Minkowski question-mark function step by step in the F# programming language
You may also check:How to resolve the algorithm Singly-linked list/Element definition step by step in the Factor programming language
You may also check:How to resolve the algorithm List comprehensions step by step in the TI-89 BASIC programming language