Consider the following:
DATA DIVISION
.
WORKING
-
STORAGE SECTION
.
01
WS
-
NUM1 PIC
9
(
4
)
VALUE
10
.
01
WS
-
NUM2 PIC
9
(
4
)
VALUE
10.
01
WS
-
NUM3 PIC
9
(
4
)
VALUE
100.
01
WS
-
NUM4 PIC
9
(
4
)
VALUE
100.
01
WS
-
NUMA PIC
9
(
4
)
VALUE
10.
01
WS
-
NUMB PIC
9
(
4
)
VALUE
10.
01
WS
-
NUMC PIC
9
(
4
)
VALUE
10.
01
WS
-
NUMD PIC
9
(
4
)
VALUE
100.
01
WS
-
NUME PIC
9
(
4
)
VALUE
10.
Using the data item list above, answer the following questions. Consider the initialized values as stated above for each question. (ie disregard the changes to data items from previous questions).
SUBTRACT
WS-NUM1 WS-NUM2
FROM
WS-NUM3
WS-NUM4.
- What are the following values after this statement?
WS
-
NUM1:
WS
-
NUM2:
WS
-
NUM3:
WS
-
NUM4:
ADD
WS-NUM1 WS-NUM2
TO
WS-NUM3
GIVING
WS-NUM4.
- What are the following values after this statement?
WS
-
NUM1:
WS
-
NUM2:
WS
-
NUM3:
WS
-
NUM4:
SUBTRACT
WS-NUMA WS-NUMB
WS-NUMC
FROM
WS-NUMD
GIVING
WS-NUME
.
- What are the following values after this statement?
WS
-
NUMA:
WS
-
NUMB:
WS
-
NUMC:
WS
-
NUMD:
WS
-
NUME:
MULTIPLY
WS-NUMA
BY
WS-NUMB WS-NUMC.
- What are the following values after this statement?
WS
-
NUMA:
WS
-
NUMB:
WS
-
NUMC:
WS
-
NUMD:
WS
-
NUME:
MULTIPLY
WS-NUMA
BY
WS-NUMB
GIVING
WS-NUMC.
- What are the following values after this statement?
WS
-
NUMA:
WS
-
NUMB:
WS
-
NUMC:
WS
-
NUMD:
WS
-
NUME:
DIVIDE
WS-NUMD
BY
7
GIVING
WS-NUMA
REMAINDER
WS-NUMB
.
- What are the following values after this statement?
WS
-
NUMA:
WS
-
NUMB:
WS
-
NUMC:
WS
-
NUMD:
WS
-
NUME:
COMPUTE
WS-NUMC
= (WS-NUM1 * WS-NUM2) - (WS-NUMA / WS-NUMB) +
WS-NUM3
.
- What are the following values after this statement?
WS
-
NUMC:
Exercise #2 (String Handling)
Consider the following:
DATA DIVISION
.
WORKING
-
STORAGE SECTION
.
01
FIELD-1 PIC
X
(
10
)
VALUE
"AAABBXBBAA".
01
FIELD-2 PIC
X
(
10
)
VALUE
"LastName".
FIELD-3 PIC
X
(
10
)
VALUE
"FirstName".
FIELD-4 PIC
X
(
20
)
VALUE
" ".
Using the data item list above, answer the following questions. Consider the initialized values as stated above for each question. (ie disregard the changes to data items from previous questions).
INSPECT
FIELD-1
REPLACING
FIRST
"B"
BY
"Z"
.
- What are the following values after this statement?
FIELD-1:
INSPECT
FIELD-1
REPLACING
ALL
"B"
BY
"C"
.
- What are the following values after this statement?
FIELD-1:
STRING
FIELD-2
DELIMITED
BY
SIZE
FIELD-3
DELIMITED
BY
SPACE
INTO
FIELD-4
ON
OVERFLOW
DISPLAY
"OVERFLOW!"
END-STRING
- What are the following values after this statement?
FIELD-2:
FIELD-3:
FIELD-4: