cobol interview question, plz help me



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

cobol interview question, plz help me

Postby naresh.galipalli » Thu Oct 21, 2010 3:07 pm

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
naresh.galipalli
 
Posts: 8
Joined: Sun Aug 08, 2010 9:19 pm
Has thanked: 0 time
Been thanked: 0 time

Re: cobol interview question, plz help me

Postby Robert Sample » Thu Oct 21, 2010 4:40 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: cobol interview question, plz help me

Postby kunal3963 » Thu Nov 11, 2010 4:41 pm

1)i thk its c
2)dnt know
kunal3963
 
Posts: 3
Joined: Thu Nov 11, 2010 3:36 pm
Has thanked: 0 time
Been thanked: 0 time

Re: cobol interview question, plz help me

Postby Robert Sample » Thu Nov 11, 2010 6:00 pm

kunal3963, your first answer is wrong -- I tested the code before I responded, which is why I answered as I did.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: cobol interview question, plz help me

Postby nm992 » Tue Nov 23, 2010 3:20 pm

FOr m eit came 9 times..

RObert:Can you please explain?
nm992
 
Posts: 43
Joined: Sun Jul 11, 2010 11:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: cobol interview question, plz help me

Postby Robert Sample » Tue Nov 23, 2010 6:03 pm

      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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post