Code for PROGRAM THAT DESCRIBES THE USE OF IF in Cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. con-if.
DATA DIVISION.
01 n1 PIC 99.
01 x1 PIC XX.
01 n3 PIC 99,99.
01 n2 PIC 99.99.
01 n4 PIC 99v99.
PROCEDURE DIVISION.
if-con1.
DISPLAY "ENTER N1".
ACCEPT n1.
DISPLAY "ENTER N2".
ACCEPT n2.
*HERE EDIT CHAR IS USED SO COMP IS NOT DONE
if n1=n2
display "n1 equal to n2".
DISPLAY "ENTER N4".
ACCEPT n4.
if n1=n4
display "n1 equal to n4".
DISPLAY "ENTER x1".
ACCEPT x1.
if n1=x1
display "n1 equal to x1".
DISPLAY "ENTER n3".
ACCEPT n3.
if n1=n3
display "n1 equal to n3".
if n1=12
NEXT SENTENCE.
if n1=12
move n1 to n2
else
NEXT SENTENCE.
display n2.
if n1=12
NEXT SENTENCE
else
move n1 to n2.
display n2.
STOP RUN.
*****************************************************************
ENTER N1
12
ENTER N2
12
n1 equal to n2