Consider the following:
DATA DIVISION.
WORKING-STORAGE SECTION.
01WS-NUM1 PIC9(4)VALUE10.
01WS-NUM2 PIC9(4)VALUE10.
01WS-NUM3 PIC9(4)VALUE100.
01WS-NUM4 PIC9(4)VALUE100.
01WS-NUMA PIC9(4)VALUE10.
01WS-NUMB PIC9(4)VALUE10.
01WS-NUMC PIC9(4)VALUE10.
01WS-NUMD PIC9(4)VALUE100.
01WS-NUME PIC9(4)VALUE10.
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).
SUBTRACTWS-NUM1 WS-NUM2FROMWS-NUM3WS-NUM4.
- What are the following values after this statement?
WS-NUM1:
WS-NUM2:
WS-NUM3:
WS-NUM4:
ADDWS-NUM1 WS-NUM2TOWS-NUM3GIVINGWS-NUM4.
- What are the following values after this statement?
WS-NUM1:
WS-NUM2:
WS-NUM3:
WS-NUM4:
SUBTRACTWS-NUMA WS-NUMBWS-NUMCFROMWS-NUMDGIVINGWS-NUME.
- What are the following values after this statement?
WS-NUMA:
WS-NUMB:
WS-NUMC:
WS-NUMD:
WS-NUME:
MULTIPLYWS-NUMABYWS-NUMB WS-NUMC.
- What are the following values after this statement?
WS-NUMA:
WS-NUMB:
WS-NUMC:
WS-NUMD:
WS-NUME:
MULTIPLYWS-NUMABYWS-NUMBGIVINGWS-NUMC.
- What are the following values after this statement?
WS-NUMA:
WS-NUMB:
WS-NUMC:
WS-NUMD:
WS-NUME:
DIVIDEWS-NUMDBY7GIVINGWS-NUMAREMAINDERWS-NUMB.
- What are the following values after this statement?
WS-NUMA:
WS-NUMB:
WS-NUMC:
WS-NUMD:
WS-NUME:
COMPUTEWS-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.
01FIELD-1 PICX(10)VALUE"AAABBXBBAA".
01FIELD-2 PICX(10)VALUE"LastName".
- FIELD-3 PICX(10)VALUE"FirstName".
- FIELD-4 PICX(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).
INSPECTFIELD-1REPLACINGFIRST"B"BY"Z".
- What are the following values after this statement?
FIELD-1:
INSPECTFIELD-1REPLACINGALL"B"BY"C".
- What are the following values after this statement?
FIELD-1:
STRINGFIELD-2DELIMITEDBYSIZE
FIELD-3DELIMITEDBYSPACE
INTOFIELD-4
ONOVERFLOWDISPLAY"OVERFLOW!"
END-STRING
- What are the following values after this statement?
FIELD-2:
FIELD-3:
FIELD-4: