Created
September 22, 2021 03:52
-
-
Save palanisamym14/3e9526f4536efd99baa8a92631eab08b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IDENTIFICATION DIVISION. | |
PROGRAM-ID. LetterSearch. | |
DATA DIVISION. | |
WORKING-STORAGE SECTION. | |
01 LetterTable. | |
02 LetterValues. | |
03 FILLER PIC X(13) | |
VALUE "ABCDCEFGHIJLM". | |
03 FILLER PIC X(13) | |
VALUE "NOPQRSTUVWXYZ". | |
02 FILLER REDEFINES LetterValues. | |
03 Letter PIC X OCCURS 26 TIMES | |
INDEXED BY LetterIdx. | |
01 LetterIn PIC X. | |
01 LetterPos PIC 99. | |
01 PrnPos PIC Z9. | |
PROCEDURE DIVISION. | |
Begin. | |
DISPLAY "Enter the letter please - " | |
WITH NO ADVANCING | |
ACCEPT LetterIn | |
SET LetterIdx LetterPos TO 1 | |
SEARCH Letter VARYING LetterPos | |
AT END DISPLAY "Letter " LetterIn " not found!" | |
WHEN Letter(LetterIdx) = LetterIn | |
MOVE LetterPos TO PrnPos | |
DISPLAY LetterIn, " is in position ", PrnPos | |
END-SEARCH | |
STOP RUN. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment