0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Gnu-COBOL IFで条件分岐

Last updated at Posted at 2020-09-03

比較演算子で書く

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
  WORKING-STORAGE SECTION.
    01 SCORE PIC 9(3).
PROCEDURE DIVISION.
  MAIN SECTION.
    MOVE 80 TO SCORE.
    IF SCORE > 60 THEN  *> 「IF 条件 THEN」
      DISPLAY "OK!"
    ELSE                *> 処理部分は「.」不要
      DISPLAY "NG!"
    END-IF.             *> 「END-IF.」
    STOP RUN.

英語っぽく書く

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
  WORKING-STORAGE SECTION.
    01 SCORE PIC 9(3).
PROCEDURE DIVISION.
  MAIN SECTION.
    MOVE 60 TO SCORE.
    IF SCORE IS GREATER THAN 60 THEN
      DISPLAY "OK!"
    ELSE
      DISPLAY "NG!"
    END-IF.
    STOP RUN.

英語っぽく 比較演算子 意味
> IS GREATER THAN ~より大きい
IS NOT > IS NOT GREATER THAN ~より大きくない
>= IS GREATER THAN OR EQUAL TO ~以上
< IS LESS THAN ~より小さい
IS NOT < IS NOT LESS THAN ~より小さくない
<= IS LESS THAN OR EQUAL TO ~以下
= IS EQUAL TO 等しい
IS NOT = IS NOT EQUAL TO に等しくない
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?