Query with unsigned variable.



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

Query with unsigned variable.

Postby Asad » Thu Mar 27, 2008 3:28 pm

Hi,
I have a small code. Am not sure about the value of the variable. :

01 NUM1 PIC 9 VALUE ZERO.
Step1: ADD -2 TO NUM1

Execute Step1 3 TIMES



What will be the value of NUM1?

Please give clarification also.
Thanks
Asad
 
Posts: 1
Joined: Thu Mar 27, 2008 3:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query with unsigned variable.

Postby arunprasad.k » Thu Mar 27, 2008 7:35 pm

Did you code this and ran?? What did you get in your output??

Didn't you get 2 as the result??

Arun.
arunprasad.k
 
Posts: 110
Joined: Thu Dec 27, 2007 5:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query with unsigned variable.

Postby qykong1986 » Fri Mar 27, 2009 7:28 am

I tried it on mainframe.
05 WS-CHANGE-OUT         PIC 9 VALUE ZERO.
...................
     ADD -2 TO WS-CHANGE-OUT.               
     DISPLAY 'FIRST STEP ' WS-CHANGE-OUT.   
     ADD -2 TO WS-CHANGE-OUT.               
     DISPLAY 'SECOND STEP ' WS-CHANGE-OUT.   
     ADD -2 TO WS-CHANGE-OUT.               
     DISPLAY 'THIRD STEP' WS-CHANGE-OUT.     

And the result :
FIRST STEP 2     
SECOND STEP 0     
THIRD STEP 2       
--------------------------------------------------------------------------------------------------------------
Thanks ^_^
Hubery.
qykong1986
 
Posts: 10
Joined: Thu Mar 19, 2009 11:28 am
Location: Shanghai.
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post