Best 5 Cobol Interview Questions

1. What is COMP-1? COMP-2?

COMP-1 - Single precision floating point. Uses 4 bytes.
COMP-2 - Double precision floating point. Uses 8 bytes.

2. How do you define a variable of COMP-1? COMP-2?

No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.

3. How many bytes does a S9(7) COMP-3 field occupy ?

Will take 4 bytes. Sign is stored as hex value in the last nibble.
General formula is INT((n/2) + 1)), where n=7 in this example.

4. How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?

Will occupy 8 bytes (one extra byte for sign).

5. How many bytes will a S9(8) COMP field occupy ?

4 bytes.