Cobol Question Pape

Preview:

DESCRIPTION

Cobol

Citation preview

Cobol Question Paper 1. Time: 30mts.

1. For each of the PICTURE clause below indicate whether it is permissible.

a. PICT IS 999.b. PICTURE AAAc. PICTURE IS 9A9A.d. PIC (5)A.e. PIC 5X.f. PIC 9(4) COMP-1 VALUE ZEROS.g. PIC 99 COMP.h. PIC COMP-2 VALUE 123.

2. Fields whose names appear in PROCEDURE DIVISION statements must be defined in the ____________________.

3. What if anything is wrong with the following:

a. 01 TRAN-REC.05 DATE-OF-SALE PIC 999999. 07 MONTH PIC 99. 07 YEAR PIC 9999.

b. 03 FIELDA PICTURE XX.

4. The COBOL Reserved Word that can be used to denote an area of a record that can not be used in processing (Procedure Division) is _______________.

5. Is the use of level numbers in the following is correct?

01 IN-REC.05 IN-NAME.

07 IN-FIRSTNAME PIC X(20).07 IN-MIDDLENAME PIC X(10).07 IN-LASTNAME PIC X(20).

05 IN-ADDRS. 10 IN-STREET PIC X(20).

10 IN-CITY PIC X(15).10 IN-STATE PIC X(20).

6. What is the length of the following record definition?

01 TRANSACTION-REC.

05 TRAN-ID PIC XX.05 TRAN-NAME PIC X(20).05 TRAN-ADDRESS. 07 TRAN-NUMBER PIC X(10). 07 TRAN-STREET PIC X(20). 07 TRAN-CITY PIC X(10).05 TRAN-CREDIT-RATING. 07 TRAN-CREDIT-TYPE PIC X. 07 TRAN-CREDIT-RATING PIC X.05 TRAN-UNIT-PRICE PIC 99V99.05 TRAN-DISCOUNT PIC V99.

7. What if any, is the syntax error in the following piece of code

01 B PIC A(7).

02 C PIC 9(4).

IF (B IS NUMERIC) ADD 10 TO C.

8. What is wrong with the following piece of code?

01 A1. 05 B PIC 99. 05 C PIC X(4).

01 A2. 05 B PIC 99V99. 05 C PIC A(4).

……..

MOVE CORRESPONDING A1 TO A2.

9. study the following

01 A PIC 99V9 VALUE 5.01 B PIC 9V9 VALUE 6.01 C PIC 99V9 VALUE 2.5.01 D PIC 99 VALUE 3.

COMPUTE A ROUNDED B C = A+B*C/DON SIZE ERROR PERFORM PRINT-ERROR

What are the contents of A.B.C after execution of the above statement?

10. how many times PARA-A is performed :

PERFORM PARA-A VARYING TIMES-COUNTER FROM 1 BY 1UNTIL TIMES-COUNTER >0.

PARA-A.MOVE P TO Q.MOVE H TO TIMES-COUNTER.

11. In the following piece of code

01 GROUP-ITEM.

05 AMOUNT-1 PIC 99V9 USAGE COMP VALUE 50.05 AMOUNT-2 PIC 9(4)V99 USAGE COMP.

MOVE ZERO TO GROUP-ITEMADD 50 TO AMOUNT-1

what will be the content of AMOUNT-1?

12. Consider the following piece of code and point out the mistakes.

PROCEDURE DIVISION.100-MAIN-PARA.

OPEN SALES-FILE PRINT-FILE.

PERFORM 200-PROCESS-PARA UNTIL NO-MORE-RECORDS = “YES”.CLOSE SALES-FILE PRINT-FILE.STOP RUN.

200-PROCESS-PARA.READ SALES-FILE

AT END MOVE “YES” TO NO-MORE-RECORDSEND-READ.MOVE SALES-FILE TO PRINT-FILE.WRITE PRINT-FILE.

13. what is the size of the following print-rec?

01 PRINT-REC.05 SL-NO PIC Z999 BLANK WHEN ZERO.05 FILLER PIC XX.05 CUSTOMER-NAME PIC X(30)BB.

05 FILLER PIC X(5). 05 BILL-NO PIC XXXBBXXXX. 05 F1 PIC X. 05 ITEM-NO PIC 9999. 05 F2 PIC XX. 05 ITEM-DESC PIC X(20). 05 F3 PIC X. 05 UNIT-RATE PIC Z(4)9.99 BLANK WHEN ZERO. 05 FILLER PIC X. 05 QTY PIC Z(3)9.999. 05 FIL PIC X. 05 ITEM-AMOUNT PIC ZZZ,ZZZ,ZZ9.99 BLANK WHEN ZERO.

14. what if anything, is wrong with the following:

a. compute total = amount1 + amont2 rounded.b. Compute amount = 210.5.c. Compute ot-hrs = ( hrs – 40. ) * 1.5 * rate-of-pay.d. Compute e = a+ B /* c.e. Compute a + b = c

15. check if the following pairs perform the same function.

a. compute total1 = 0.Move zeros to total1.

b. compute x = a * y – b * z.compute x = ( a * y ) – ( b * z ).

c. compute x = a – b * c – d.compute x = ( a – b ) * ( c – d ).

16. compute the record length.

01 MASTER-REC. 05 IDENT-OUT PIC X(34). 05 SALES-AMT-OUT PIC 999V99 usage comp. 05 DISC-PERCENT-OUT PIC V99 usage comp. 05 DISC-AMT-OUT PIC 999V99 usage comp-3. 05 NET-AMT-OUT PIC 999V99.

17. what is the length of the following print records.

01 HDR-1. 05 filler PIC X(15) VALUE SPACES.

05 filler PIC X(13) VALUE 'CLASS GRADES'.

05 filler PIC X(22) VALUE SPACES. 05 DATE-OUT. 10 MONTH-OUT PIC XX. 10 f1 PIC X VALUE '/'. 10 DAY-OUT PIC XX. 10 f2 PIC X VALUE '/'. 10 YEAR-OUT PIC XXXX. 05 filler PIC X(11). 05 filler PIC X(5) VALUE 'PAGE'. 05 PAGE-NO PIC 99 blank when ZERO.

18. what is the length of the following

01 TL-FINAL-TOTAL-LINE. 05 fil PIC X(54) VALUE 'TOTAL UNIVERSITY BUDGET WILL BE INCREASED BY '.

05 TL-TOTAL-COST PIC $ZZZ,ZZZ,ZZ9.99.

19. compute the length of

01 WS-WORK-AREAS. 05 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'. 05 WS-PROFESSOR-CTR PIC 9(3) VALUE ZEROS. 05 WS-ASSOCIATE-CTR PIC 9(3) VALUE ZEROS. 05 WS-ASSISTANT-CTR PIC 9(3) VALUE ZEROS. 05 WS-INSTRUCTOR-CTR PIC 9(3) VALUE ZEROS. 05 WS-PROFESSOR-COST PIC 9(7)V99 comp-3 sync right VALUE ZEROS. 05 WS-ASSOCIATE-COST PIC 9(7)V99 comp-3 sync right VALUE ZEROS. 05 WS-ASSISTANT-COST PIC 9(7)V99 comp-3 sync right VALUE ZEROS. 05 WS-INSTRUCTOR-COST PIC 9(7)V99 comp-3 sync right VALUE ZEROS. 05 WS-TOTAL-COST PIC 9(9)V99 comp-3 sync right VALUE ZEROS. 05 NEW-SAL PIC 9(7)V99 VALUE ZEROS.

20. Check the following code snippet. State if the output file will be created properly?

100-MAIN-MODULE. OPEN INPUT IN-EMPLOYEE-FILE OUTPUT OUT-SALARY-FILE. MOVE SPACES TO OUT-SALARY-REC. PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO ' READ IN-EMPLOYEE-FILE AT END MOVE 'NO ' TO ARE-THERE-MORE-RECORDS END-READ END-PERFORM. CLOSE IN-EMPLOYEE-FILE OUT-SALARY-FILE. STOP RUN. 200-PROCESS-RTN. MOVE IN-EMPLOYEE-NAME TO OUT-EMPLOYEE-NAME MOVE IN-SALARY TO OUT-SALARY WRITE OUT-SALARY-REC.

Recommended