Cobol Question Pape

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

Cobol Question Paper 1.

Time: 30mts.

1. For each of the PICTURE clause below indicate whether it is permissible. a. b. c. d. e. f. g. h. PICT IS 999. PICTURE AAA PICTURE IS 9A9A. PIC (5)A. PIC 5X. PIC 9(4) COMP-1 VALUE ZEROS. PIC 99 COMP. 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? 1 IN-REC. 5 IN-NAME. 07 IN-FIRSTNAME 07 IN-MIDDLENAME 07 IN-LASTNAME 05 IN-ADDRS. 10 IN-STREET 10 IN-CITY 10 IN-STATE

PIC X(20). PIC X(10). PIC X(20). PIC X(20). PIC X(15). PIC X(20).

6. What is the length of the following record definition? 1 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 02 C

PIC A(7). 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/D ON 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 1 UNTIL 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-ITEM ADD 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-RECORDS END-READ. MOVE SALES-FILE TO PRINT-FILE. WRITE PRINT-FILE. 13. what is the size of the following print-rec? 1 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. b. c. d. e. compute total = amount1 + amont2 rounded. Compute amount = 210.5. Compute ot-hrs = ( hrs 40. ) * 1.5 * rate-of-pay. Compute e = a+ B /* c. 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 ). compute x = a b * c d. compute x = ( a b ) * ( c d ). 16. compute the record length. 01 05 05 05 05 05 MASTER-REC. IDENT-OUT PIC X(34). SALES-AMT-OUT PIC 999V99 usage comp. DISC-PERCENT-OUT PIC V99 usage comp. DISC-AMT-OUT PIC 999V99 usage comp-3. NET-AMT-OUT PIC 999V99. c.

17. what is the length of the following print records. 01 HDR-1. 05 filler PIC X(15) VALUE SPACES.

05 filler 05 05

05 05 05

PIC X(13) VALUE 'CLASS GRADES'. filler PIC X(22) VALUE SPACES. 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. filler PIC X(11). filler PIC X(5) VALUE 'PAGE'. 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.

You might also like