Page 1 of 1

cobol interview question, plz help me

PostPosted: Thu Oct 21, 2010 3:07 pm
by naresh.galipalli
please answer anyone, help me. iam new to mainframes.

PERFORM ACCULATE-TOTALS VARYING A FROM 1 BY 2 UNTIL A > 2 AFTER B FROM 1 BY 1 UNTIL B > 2 AFTER C FROM 2 BY -1 UNTIL C < -9 How many times accumulate-totals will be executed?

a) 10
b) 09
c) 11
d) infinite loop.

How is sign stored in Packed Decimal fields?

a) Sign is stored as a hex value in the last nibble (4 bits ) of the storage
b) Sign is over punched with numeric value stored in the last bite
c) Sign is stored in hex value in first 4 bits of storage
d) None of the above

Re: cobol interview question, plz help me

PostPosted: Thu Oct 21, 2010 4:40 pm
by Robert Sample
For your first question, how about (E) none of the above? The manual can help you figure out why this is the answer.

For your second question, read the manual. http://www-01.ibm.com/software/awdtools/cobol/zos/library/ and bookmark it since you'll need to reference it often.

Re: cobol interview question, plz help me

PostPosted: Thu Nov 11, 2010 4:41 pm
by kunal3963
1)i thk its c
2)dnt know

Re: cobol interview question, plz help me

PostPosted: Thu Nov 11, 2010 6:00 pm
by Robert Sample
kunal3963, your first answer is wrong -- I tested the code before I responded, which is why I answered as I did.

Re: cobol interview question, plz help me

PostPosted: Tue Nov 23, 2010 3:20 pm
by nm992
FOr m eit came 9 times..

RObert:Can you please explain?

Re: cobol interview question, plz help me

PostPosted: Tue Nov 23, 2010 6:03 pm
by Robert Sample
      01  GRP.
          05  A                       PIC S9(04) VALUE ZERO.
          05  B                       PIC S9(04) VALUE ZERO.
          05  C                       PIC S9(04) VALUE ZERO.
          05  TIMES-EXEC              PIC  9(04) VALUE ZERO.
      PROCEDURE DIVISION.
      MAIN-PARA.
          PERFORM ACCULATE-TOTALS
              VARYING A FROM 1 BY  2 UNTIL A > 2
                AFTER B FROM 1 BY  1 UNTIL B > 2
                AFTER C FROM 2 BY -1 UNTIL C < -9
            .
          DISPLAY 'TIMES EXECUTED ' TIMES-EXEC.
          STOP RUN.

      ACCULATE-TOTALS.
          DISPLAY 'A ' A ' B ' B ' C ' C .
          ADD 1                       TO  TIMES-EXEC.
produces results of
 A 000A B 000A C 000B
 A 000A B 000A C 000A
 A 000A B 000A C 000{
 A 000A B 000A C 000J
 A 000A B 000A C 000K
 A 000A B 000A C 000L
 A 000A B 000A C 000M
 A 000A B 000A C 000N
 A 000A B 000A C 000O
 A 000A B 000A C 000P
 A 000A B 000A C 000Q
 A 000A B 000A C 000R
 A 000A B 000B C 000B
 A 000A B 000B C 000A
 A 000A B 000B C 000{
 A 000A B 000B C 000J
 A 000A B 000B C 000K
 A 000A B 000B C 000L
 A 000A B 000B C 000M
 A 000A B 000B C 000N
 A 000A B 000B C 000O
 A 000A B 000B C 000P
 A 000A B 000B C 000Q
 A 000A B 000B C 000R
 TIMES EXECUTED 0024
since these are signed variables, 000A is 1, 000B is 2, 000R is -9 and so forth.