Which of the following are syntactically correct? (1) 01 REC-1 PIC SX(4). (2) 01 REC-2 PIC S9(4). (3) 01 REC-1 PIC V99. (4) 01 REC-1 PIC P99. (5) 01 REC-1 PIC 9(4)S. (6) 01 REC 1 PIC X(4).

  1. 2, 3 and 6

  2. 3, 4 and 6

  3. 1, 2 and 3

  4. 2, 3 and 4


Correct Option: D

AI Explanation

To determine which of the given options are syntactically correct, we need to understand the syntax rules for COBOL picture clauses.

In COBOL, the PICTURE clause is used to define the format and type of data items. It consists of a combination of characters that represent the format of the data item.

Let's go through each option to determine its correctness:

Option A) 01 REC-1 PIC SX(4) This option is incorrect. The 'S' in the PICTURE clause indicates a signed numeric field, but 'X' is not a valid format for a numeric field. The correct format for a signed numeric field would be 'S9' followed by the number of digits.

Option B) 01 REC-2 PIC S9(4) This option is correct. 'S9(4)' represents a signed numeric field with 4 digits.

Option C) 01 REC-1 PIC V99 This option is correct. 'V99' represents a numeric field with 2 decimal places.

Option D) 01 REC-1 PIC P99 This option is correct. 'P99' represents a numeric field with 2 decimal places and an implicit decimal point.

Option E) 01 REC-1 PIC 9(4)S This option is incorrect. The 'S' should come before the number of digits in a signed numeric field. The correct format would be 'S9(4)'.

Option F) 01 REC 1 PIC X(4) This option is incorrect. There should be a hyphen (-) between 'REC' and '1' in the level number. The correct format would be '01 REC-1 PIC X(4)'.

Based on the above analysis, the correct options are 2, 3, and 4. Therefore, the correct answer is D.

Find more quizzes: