RAMESH KRISHNA REDDY mainframe discussion forum - cobol, db2,cics,jcl,file-aid,changeman,interview questions
Online Tutorials   | PREV  | TOP  | NEXT



DRONA SERIES
COBOL STUDY MATERIAL


COBOL VERBS - DIVIDE



   
 

COBOL VERBS - DIVIDE






DIVIDE Verb DIVIDE statement divide one number by another and store the result. Format 1. DIVIDE < literal-1 / data-item-1 > INTO data-item-1... Format 2. DIVIDE < literal-1 / data-item-1 > INTO < literal-2 / data-item-2 > GIVING data-item-3... REMAINDER data-item-4... Examples - (a) DIVIDE WS-A INTO WS-B. Above example is equals to WS-B = WS-B / WS-A. WS-B value is divided by WS-A and the result will be stored in WS-B. (b) DIVIDE WS-A INTO WS-B GIVING WS-C. Above example is equals to WS-C = WS-B / WS-A. WS-B value is divided by WS-A and the result will be stored in WS-C. No change to WS-B, WS-A values. (c) DIVIDE WS-A INTO WS-B GIVING WS-C REMAINDER WS-D. This statement very similar to example (b), except using REMAINDER word. after dividing WS-B by WS-A remainder value will be stored in WS-D. WS-A value is 100 WS-B value is 350 100 ) 350 ( 3 <--- This value will be moved to WS-C. 300 ---- 50 <--- Remainder, this value will be moved to WS-D. ---- Using BY instead of INTO.... we can use INTO instead of BY in the above format2. But, make sure that values/data-items used for calcualtion needs to be exchanged to get the same result. example (b) can be rewrite using word BY , to get same result in WS-C, need to swap WS-B, WS-A places. i.e, state should look like DIVIDE WS-B BY WS-A GIVING WS-C. equals WS-C = WS-B / WS-A.
    

NEXT CHAPTER TOPIC : COBOL


                                   



Previous chapter in COBOL tutorial Starting of COBOL tutorial Next chapter in COBOL tutorial


Visit COBOL books section in this site for good books




Home | Donations | Online Tutorials | Books | Entertainment | Contactme | privacy |  sql tutorial | jcl interview questions | JCL Tutorial | JCL Tutorial - chapter1 | JCL Tutorial - chapter2 | JCL Tutorial - chapter3 | JCL Tutorial - chapter4 | JCL Tutorial - chapter5 | JCL Tutorial - chapter6 | JCL Tutorial - chapter7 | JCL Tutorial - chapter8 | JCL Tutorial - chapter9 | JCL Tutorial - chapter10 | JCL Tutorial - chapter11