Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

PROGRAM TO DISPLAY THE PATTERN OF NUMBERS IN REVERSE PATTERN

Posted By: Reginheraht Fischer     Category: Cobol     Views: 8527

PROGRAM TO DISPLAY THE PATTERN :
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Code for PROGRAM TO DISPLAY THE PATTERN OF NUMBERS IN REVERSE PATTERN in Cobol

       Identification Division.
       Program-Id. Display-of-Pattern-No-4.

       Environment Division.

       Data Division.
       Working-Storage Section.
       77 N       Pic 9.
       77 Counter Pic 9 Value 1.
       77 j       Pic 9 Value 1.
       77 Temp-N  Pic 9.

      * The Designing of the Main Screen of the Program.

       Screen Section.
       01 Main-Screen.
           02 Blank-Screen.
           02 Line 2 Column 15 "The Pattern to be Displayed is : "
             Reverse-Video Blink.
           02 Line 4 Column 15 "1  2  3  4".
           02 Line 5 Column 15 "1  2  3".
           02 Line 6 Column 15 "1  2".
           02 Line 7 Column 15 "1".
           02 Line 10 Column 15 "Please Enter the No. of Lines for the a
              "bove Pattern :".
           02 Line 10 Column 70 Pic 9 To N.

       Procedure Division.

       Main-Para.
           Display Main-Screen.
           Accept Main-Screen.
           Move 12 To Lin.
           Move 15 To Col.
           Move N To Temp-N.
           Perform Lines-Loop Varying Counter From 1 By 1 Until
           ( Counter > N ).
           Stop Run.

      * The Main Loop of varying the Lines is Below.

       Lines-Loop.
           Move 1 To j.
           Perform Display-Loop Until j > Temp-N.
           Add 1 To Lin.
           Move 15 To Col.
           Compute Temp-N = Temp-N - 1.

      * The Main Loop of Displaying the Pattern is Below.

       Display-Loop.
           Display(Lin, Col) j.
           Add 3 To Col.
           Compute j = j + 1.
  
Share: 



Reginheraht Fischer
Reginheraht Fischer author of PROGRAM TO DISPLAY THE PATTERN OF NUMBERS IN REVERSE PATTERN is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!